MCPcopy Create free account
hub / github.com/FastFlowLM/FastFlowLM / profiler

Class profiler

src/include/utils/profiler.hpp:12–82  ·  view source on GitHub ↗

\brief profiler class

Source from the content-addressed store, hash-verified

10
11/// \brief profiler class
12class profiler{
13public:
14 profiler(){
15 this->start_time = time_utils::now();
16 this->counter = 0;
17 this->total_time = {0, "us"};
18 }
19
20 /// \brief start the profiler
21 time_utils::time_point start(){
22 this->start_time = time_utils::now();
23 return this->start_time;
24 }
25
26 /// \brief stop the profiler
27 /// \param elements the number of elements
28 /// \param overwrite the overwrite flag
29 time_utils::time_point stop(size_t elements, bool overwrite = false){
30 time_utils::time_point end_time = time_utils::now();
31 time_utils::time_with_unit duration = time_utils::duration_us(this->start_time, end_time);
32 this->total_time.first += duration.first;
33 if (overwrite){
34 this->counter = elements;
35 }
36 else{
37 this->counter += elements;
38 }
39 return end_time;
40 }
41
42 /// \brief reset the profiler
43 void reset(){
44 this->start_time = time_utils::now();
45 this->counter = 0;
46 this->total_time = {0, "us"};
47 }
48
49 /// \brief get the total time
50 /// \return the total time
51 time_utils::time_with_unit get_total_time(){
52 time_utils::time_with_unit auto_time = time_utils::re_unit(this->total_time);
53 return auto_time;
54 }
55
56 /// \brief get the average time
57 /// \return the average time
58 float get_average_time(){
59 time_utils::time_with_unit time_in_second = time_utils::cast_to_s(this->total_time);
60 return time_in_second.first / this->counter;
61 }
62
63 /// \brief get the average speed
64 /// \return the average speed
65 float get_average_speed(){
66 time_utils::time_with_unit time_in_second = time_utils::cast_to_s(this->total_time);
67 return this->counter / time_in_second.first;
68 }
69

Callers 2

AutoModelMethod · 0.85
WhisperMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected