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.
- Warning
- There is a non-negligible overhead to starting and stopping the timer. So for one you should not use this in production code. For another you should measure the overhead with a separate benchmark instance that starts and stops immediately and subtract that from the measured time (getEntryTime provides that option).
Definition at line 50 of file Benchmark.h.