Lumiera
0.pre.03
»edit your freedom«
|
Go to the source code of this file.
Functions to perform (multithreaded) timing measurement on a given functor.
This helper simplifies micro benchmarks of isolated implementation details. The test subject, given as function object or lambda, is invoked numerous times within a tight loop. In the multithreaded variant, the lambda is copied into N threads and performed in each thread in parallel; after waiting on termination of the test threads, results are summed up and then averaged into milliseconds per single invocation. The actual timing measurement relies on chrono::duration
, which means to count micro ticks of the OS.
Definition in file microbenchmark.hpp.
#include "lib/meta/function.hpp"
#include "lib/scoped-collection.hpp"
#include "lib/sync-barrier.hpp"
#include "lib/thread.hpp"
#include "lib/test/microbenchmark-adaptor.hpp"
#include <chrono>
Typedefs | |
using | CLOCK_SCALE = std::micro |
Functions | |
template<class FUN > | |
size_t | benchmarkLoop (FUN const &testSubject, const size_t repeatCnt=DEFAULT_RUNS) |
Benchmark building block to invoke a functor or λ in a tight loop, passing the current loop index and capturing a result checksum value. More... | |
template<class FUN > | |
double | benchmarkTime (FUN const &invokeTestCode, const size_t repeatCnt=1) |
Helper to invoke a functor or λ to observe its running time. More... | |
template<class FUN > | |
auto | microBenchmark (FUN const &testSubject, const size_t repeatCnt=DEFAULT_RUNS) |
perform a simple looped microbenchmark. More... | |
template<size_t nThreads, class FUN > | |
auto | threadBenchmark (FUN const &subject, const size_t repeatCnt=DEFAULT_RUNS) |
perform a multithreaded microbenchmark. More... | |
Variables | |
constexpr size_t | DEFAULT_RUNS = 10'000'000 |
Namespaces | |
lib | |
Implementation namespace for support and library code. | |
|
inline |
Helper to invoke a functor or λ to observe its running time.
invokeTestLoop | the test (complete including loop) invoked once |
repeatCnt | number of repetitions to divide the timing measurement |
Definition at line 85 of file microbenchmark.hpp.
References lib::test::benchmarkTime().
Referenced by lib::test::benchmarkTime().
|
inline |
Benchmark building block to invoke a functor or λ in a tight loop, passing the current loop index and capturing a result checksum value.
Definition at line 104 of file microbenchmark.hpp.
References lib::test::benchmarkLoop().
Referenced by lib::test::benchmarkLoop().
|
inline |
perform a simple looped microbenchmark.
testSubject | the operation to test as functor or λ |
(microseconds, checksum)
Definition at line 127 of file microbenchmark.hpp.
References lib::test::microBenchmark().
Referenced by lib::test::microBenchmark().
|
inline |
perform a multithreaded microbenchmark.
This function fires up a number of threads and invokes the given test subject repeatedly.
number | of threads to run in parallel |
subject | function to be timed in parallel |
repeatCnt | loop-count within each thread |
(microseconds, checksum)
combining the averaged invocation time and a compounded checksum from all threads. nThreads
copies of this function will run in parallelDefinition at line 156 of file microbenchmark.hpp.
References lib::test::threadBenchmark().
Referenced by lib::test::threadBenchmark().