profiler  0.0
Counter.h
1 #ifndef PROFILER_SRC_MOLPRO_PROFILER_TREE_COUNTER_H
2 #define PROFILER_SRC_MOLPRO_PROFILER_TREE_COUNTER_H
3 #include <molpro/profiler/Timer.h>
4 
5 #include <map>
6 #include <memory>
7 #include <string>
8 
9 namespace molpro {
10 namespace profiler {
11 
15 class Counter {
16 public:
17  Counter() = default;
18  Counter(bool with_cpu_time, bool with_wall_time);
19 
21  Counter(size_t call_count_, size_t operation_count_, double wall_time_, double cpu_time_, bool with_cpu_time,
22  bool with_wall_time);
23 
25  Counter& start();
26 
28  Counter& stop();
29 
31  Counter& reset();
32 
34  void add_operations(size_t ops) { operation_count += ops; }
35 
37  void operator+=(const Counter& other);
38 
39  size_t get_call_count() const { return call_count; }
40  size_t get_operation_count() const { return operation_count; }
41  const Timer& get_cpu() const { return cpu; }
42  const Timer& get_wall() const { return wall; }
43 
44 protected:
45  size_t call_count = 0;
46  size_t operation_count = 0;
47  Timer cpu = {Timer::cpu, true};
48  Timer wall = {Timer::wall, true};
49 };
50 
51 } // namespace profiler
52 } // namespace molpro
53 
54 #endif // PROFILER_SRC_MOLPRO_PROFILER_TREE_COUNTER_H
Resource counter used for storing operation count, call count, timing information.
Definition: Counter.h:15
Counter & start()
Start timing, and increment call_count;.
Definition: Counter.cpp:5
Counter & reset()
Reset all counters and timers.
Definition: Counter.cpp:25
size_t get_operation_count() const
Definition: Counter.h:40
void add_operations(size_t ops)
Add to the operation count.
Definition: Counter.h:34
void operator+=(const Counter &other)
Accumulates all attributes.
Definition: Counter.cpp:18
const Timer & get_cpu() const
Definition: Counter.h:41
size_t get_call_count() const
Definition: Counter.h:39
Timer wall
wall time
Definition: Counter.h:48
size_t call_count
number of times this node was merged
Definition: Counter.h:45
Counter & stop()
Stop timing.
Definition: Counter.cpp:12
const Timer & get_wall() const
Definition: Counter.h:42
size_t operation_count
number of operations performed
Definition: Counter.h:46
Timer cpu
cpu time
Definition: Counter.h:47
Measures cpu or wall time. Can be constructed as a dummy that is always stopped.
Definition: Timer.h:40
@ cpu
Definition: Timer.h:42
@ wall
Definition: Timer.h:42
Definition: Profiler.h:5