Skip to content

Commit da39d78

Browse files
committed
Clean up cpu_timer
1 parent 49bcb1d commit da39d78

File tree

6 files changed

+14
-100
lines changed

6 files changed

+14
-100
lines changed

dynadjust/dynadjust/dnaadjust/dnaadjust.hpp

Lines changed: 1 addition & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -106,30 +106,7 @@ namespace networkadjust {
106106

107107
extern std::mutex maxCorrMutex;
108108

109-
// Moved cpu_timer to dnatimer.hpp
110-
class cpu_timer {
111-
public:
112-
struct cpu_times {
113-
std::chrono::nanoseconds wall;
114-
std::chrono::nanoseconds user;
115-
std::chrono::nanoseconds system;
116-
};
117-
118-
cpu_timer() { start(); }
119-
120-
void start() {
121-
start_time_ = std::chrono::high_resolution_clock::now();
122-
}
123-
124-
cpu_times elapsed() const {
125-
auto end_time = std::chrono::high_resolution_clock::now();
126-
auto wall_duration = std::chrono::duration_cast<std::chrono::nanoseconds>(end_time - start_time_);
127-
return {wall_duration, wall_duration, wall_duration}; // For simplicity, user and system = wall
128-
}
129-
130-
private:
131-
std::chrono::high_resolution_clock::time_point start_time_;
132-
};
109+
using dynadjust::cpu_timer;
133110

134111
// forward declaration of dna_adjust
135112
class dna_adjust;

dynadjust/dynadjust/dnageoidwrapper/dnageoidwrapper.hpp

Lines changed: 3 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -63,35 +63,14 @@
6363
#include <include/functions/dnatemplatedatetimefuncs.hpp>
6464
#include <include/functions/dnastrmanipfuncs.hpp>
6565
#include <include/functions/dnatemplatefuncs.hpp>
66+
#include <include/functions/dnatimer.hpp>
6667

6768
#include <dynadjust/dnageoid/dnageoid.hpp>
6869

6970
using namespace dynadjust::geoidinterpolation;
7071

71-
// High-precision timer class to replace boost::timer::cpu_timer
72-
class cpu_timer {
73-
public:
74-
struct cpu_times {
75-
std::chrono::nanoseconds wall;
76-
std::chrono::nanoseconds user;
77-
std::chrono::nanoseconds system;
78-
};
79-
80-
cpu_timer() { start(); }
81-
82-
void start() {
83-
start_time_ = std::chrono::high_resolution_clock::now();
84-
}
85-
86-
cpu_times elapsed() const {
87-
auto end_time = std::chrono::high_resolution_clock::now();
88-
auto wall_duration = std::chrono::duration_cast<std::chrono::nanoseconds>(end_time - start_time_);
89-
return {wall_duration, wall_duration, wall_duration}; // For simplicity, user and system = wall
90-
}
91-
92-
private:
93-
std::chrono::high_resolution_clock::time_point start_time_;
94-
};
72+
// Use cpu_timer from dnatimer.hpp
73+
using dynadjust::cpu_timer;
9574

9675
bool CreateNTv2Grid(dna_geoid_interpolation* g, const char* dat_gridfilePath, const n_file_par* grid);
9776
bool createGridIndex(dna_geoid_interpolation* g, const char* gridfilePath, const char* gridfileType, const int& quiet);

dynadjust/dynadjust/dnaimportwrapper/dnaimportwrapper.hpp

Lines changed: 2 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@
6262
#include <include/functions/dnaiostreamfuncs.hpp>
6363
#include <include/functions/dnafilepathfuncs.hpp>
6464
#include <include/functions/dnastrmanipfuncs.hpp>
65+
#include <include/functions/dnatimer.hpp>
6566

6667
#include <dynadjust/dnaimport/dnainterop.hpp>
6768

@@ -72,30 +73,7 @@ using namespace dynadjust::datum_parameters;
7273
extern bool running;
7374
extern std::mutex cout_mutex;
7475

75-
// High-precision timer class to replace boost::timer::cpu_timer
76-
class cpu_timer {
77-
public:
78-
struct cpu_times {
79-
std::chrono::nanoseconds wall;
80-
std::chrono::nanoseconds user;
81-
std::chrono::nanoseconds system;
82-
};
83-
84-
cpu_timer() { start(); }
85-
86-
void start() {
87-
start_time_ = std::chrono::high_resolution_clock::now();
88-
}
89-
90-
cpu_times elapsed() const {
91-
auto end_time = std::chrono::high_resolution_clock::now();
92-
auto wall_duration = std::chrono::duration_cast<std::chrono::nanoseconds>(end_time - start_time_);
93-
return {wall_duration, wall_duration, wall_duration}; // For simplicity, user and system = wall
94-
}
95-
96-
private:
97-
std::chrono::high_resolution_clock::time_point start_time_;
98-
};
76+
using dynadjust::cpu_timer;
9977

10078
class dna_import_thread
10179
{

dynadjust/dynadjust/dnasegment/dnasegment.hpp

Lines changed: 3 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@
6060
#include <include/io/bms_file.hpp>
6161
#include <include/io/map_file.hpp>
6262
#include <include/io/seg_file.hpp>
63+
#include <include/functions/dnatimer.hpp>
6364

6465
using namespace dynadjust::measurements;
6566
using namespace dynadjust::exception;
@@ -68,30 +69,8 @@ using namespace dynadjust::iostreams;
6869
namespace dynadjust {
6970
namespace networksegment {
7071

71-
// High-precision timer class to replace boost::timer::cpu_timer
72-
class cpu_timer {
73-
public:
74-
struct cpu_times {
75-
std::chrono::nanoseconds wall;
76-
std::chrono::nanoseconds user;
77-
std::chrono::nanoseconds system;
78-
};
79-
80-
cpu_timer() { start(); }
81-
82-
void start() {
83-
start_time_ = std::chrono::high_resolution_clock::now();
84-
}
85-
86-
cpu_times elapsed() const {
87-
auto end_time = std::chrono::high_resolution_clock::now();
88-
auto wall_duration = std::chrono::duration_cast<std::chrono::nanoseconds>(end_time - start_time_);
89-
return {wall_duration, wall_duration, wall_duration}; // For simplicity, user and system = wall
90-
}
91-
92-
private:
93-
std::chrono::high_resolution_clock::time_point start_time_;
94-
};
72+
// Use cpu_timer from dnatimer.hpp
73+
using dynadjust::cpu_timer;
9574

9675
// This class is exported from the dnaSegment.dll
9776
#ifdef _MSC_VER

dynadjust/dynadjust/metadata/metadata.cpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ std::mutex import_file_mutex;
3434
#include <include/functions/dnafilepathfuncs.hpp>
3535
#include <include/functions/dnastrmanipfuncs.hpp>
3636
#include <include/functions/dnastrutils.hpp>
37+
#include <include/functions/dnatimer.hpp>
3738

3839
#include <include/parameters/dnadatum.hpp>
3940

@@ -451,7 +452,7 @@ int main(int argc, char* argv[])
451452
std::cout << "+ Parsing: " << std::endl;
452453
}
453454

454-
boost::timer::cpu_timer time; // constructor of boost::timer::cpu_timer calls start()
455+
cpu_timer time; // constructor of cpu_timer calls start()
455456

456457
std::ifstream* ifsDynaML_;
457458
size_t sifsFileSize_, measurementUpdateCount(0), unsureFrameCount(0), unsureEpochCount(0);
@@ -572,8 +573,8 @@ int main(int argc, char* argv[])
572573
}
573574

574575
// Finish up
575-
time.stop();
576-
elapsed_time = boost::posix_time::milliseconds(time.elapsed().wall/MILLI_TO_NANO);
576+
auto elapsed = time.elapsed();
577+
elapsed_time = boost::posix_time::milliseconds(elapsed.wall.count() / MILLI_TO_NANO);
577578

578579
if (!p.g.quiet)
579580
{

dynadjust/dynadjust/metadata/precompile.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
/// \cond
1616
#include <windows.h>
1717

18-
#include <boost/timer/timer.hpp>
18+
#include <include/functions/dnatimer.hpp>
1919
#include <boost/date_time/posix_time/posix_time.hpp>
2020
#include <boost/thread.hpp>
2121
#include <boost/thread/mutex.hpp>

0 commit comments

Comments
 (0)