![]() |
ATLAS Offline Software
|
this is a simple benchmarking helper class wrapping timers from std::chrono More...
#include <Benchmark.h>
Public Member Functions | |
| Benchmark (const std::string &val_name="", unsigned val_batchSize=1) | |
| ~Benchmark () | |
| void | setSilence () |
| std::optional< float > | getEntryTime (float emptyTime) const |
| auto | getTotalTime () const |
| void | startTimer () |
| void | stopTimer () |
Static Public Member Functions | |
| static float | getTickDuration () |
Private Attributes | |
| std::string | m_name |
| std::chrono::time_point< std::chrono::high_resolution_clock > | m_start |
| std::chrono::high_resolution_clock::duration | m_ticks {} |
| accumulated time m_ticks | |
| std::uint64_t | m_count = 0 |
| the number of times the timer has been started | |
| unsigned | m_batchSize = 1 |
| the number of calls per batch | |
| bool | m_silence = false |
| whether to suppress output | |
this is a simple benchmarking helper class wrapping timers from std::chrono
Essentially this just takes care of all the bookkeeping around starting and stopping the timer, accumulating the total time, and computing the average time per entry. The compiler should (hopefully) inline the performance sensitive parts to avoid the overhead. This allows to perform fine-grained and precise measurements of various parts of the code and is extensively used in the PHYSLITE tests.
By default this will just print the average time per entry in the destructor, however this is not scalable to large number of separate benchmarks. So in general you should set it to silent and use getEntryTime to retrieve the time instead. At some point I may also remove the automatic printing altogether and make that the default behavior.
This also allows to specify a batch size, which is useful when we process multiple events at once and want to compare to time per event with other batch sizes or single-event processing.
Definition at line 50 of file Benchmark.h.
|
inline |
Definition at line 56 of file Benchmark.h.
|
inline |
Definition at line 63 of file Benchmark.h.
|
inline |
Definition at line 74 of file Benchmark.h.
|
inlinestatic |
Definition at line 86 of file Benchmark.h.
|
inline |
Definition at line 81 of file Benchmark.h.
|
inline |
Definition at line 69 of file Benchmark.h.
|
inline |
Definition at line 92 of file Benchmark.h.
|
inline |
Definition at line 97 of file Benchmark.h.
|
private |
the number of calls per batch
Definition at line 120 of file Benchmark.h.
|
private |
the number of times the timer has been started
Definition at line 117 of file Benchmark.h.
|
private |
Definition at line 109 of file Benchmark.h.
|
private |
whether to suppress output
Definition at line 123 of file Benchmark.h.
|
private |
Definition at line 111 of file Benchmark.h.
|
private |