1 #ifndef WREPORT_BENCHMARK_H 2 #define WREPORT_BENCHMARK_H 26 unsigned run_count = 0;
35 void collect(std::function<
void()> f);
43 virtual void start_benchmark(
const Benchmark& b) = 0;
44 virtual void end_benchmark(
const Benchmark& b) = 0;
45 virtual void start_iteration(
const Benchmark& b,
unsigned cur,
47 virtual void end_iteration(
const Benchmark& b,
unsigned cur,
49 virtual void test_failed(
const Benchmark& b, std::exception& e) = 0;
63 void start_benchmark(
const Benchmark& b)
override;
64 void start_iteration(
const Benchmark& b,
unsigned cur,
65 unsigned total)
override;
66 void end_iteration(
const Benchmark& b,
unsigned cur,
67 unsigned total)
override;
68 void end_benchmark(
const Benchmark& b)
override;
69 void test_failed(
const Benchmark& b, std::exception& e)
override;
80 unsigned repetitions = 10;
82 std::vector<Task*> tasks;
124 virtual void main() = 0;
130 std::vector<Benchmark*> benchmarks;
157 static void basic_run(
int argc,
const char* argv[]);
Basic progress implementation writing progress information to the given output stream.
Definition: benchmark.h:56
Collect all existing benchmarks.
Definition: benchmark.h:128
Base class for all benchmarks.
Definition: benchmark.h:75
virtual void teardown_iteration()
Tear down the environment for an iteration of this benchmark.
Definition: benchmark.h:115
static void basic_run(int argc, const char *argv[])
Basic implementation of a main function that runs all benchmarks linked into the program.
void run(Progress &progress)
Run the benchmark and collect timings.
virtual void teardown_main()
Tear down the environment for this benchmark.
Definition: benchmark.h:101
void print_timings()
Print timings to stdout.
virtual void setup_iteration()
Set up the environment for an iteration of this benchmark.
Definition: benchmark.h:108
String functions.
Definition: benchmark.h:13
Notify of progress during benchmark execution.
Definition: benchmark.h:39
virtual void main()=0
Main body of this benchmark.
Collect timings for one task.
Definition: benchmark.h:19
virtual void setup_main()
Set up the environment for this benchmark.
Definition: benchmark.h:94
void add(Benchmark *b)
Add a benchmark to this registry.