1#ifndef WREPORT_BENCHMARK_H
2#define WREPORT_BENCHMARK_H
26 unsigned run_count = 0;
32 Task(
Benchmark* parent,
const std::string& name);
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;
61 BasicProgress(FILE* out = stdout, FILE* err = stderr);
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;
86 Benchmark(
const std::string& name);
130 std::vector<Benchmark*> benchmarks;
String functions.
Definition benchmark.h:13
Base class for all benchmarks.
Definition benchmark.h:76
virtual void teardown_main()
Tear down the environment for this benchmark.
Definition benchmark.h:101
virtual void main()=0
Main body of this benchmark.
virtual void teardown_iteration()
Tear down the environment for an iteration of this benchmark.
Definition benchmark.h:115
void print_timings()
Print timings to stdout.
virtual void setup_main()
Set up the environment for this benchmark.
Definition benchmark.h:94
void run(Progress &progress)
Run the benchmark and collect timings.
virtual void setup_iteration()
Set up the environment for an iteration of this benchmark.
Definition benchmark.h:108
Notify of progress during benchmark execution.
Definition benchmark.h:40
Collect all existing benchmarks.
Definition benchmark.h:129
void add(Benchmark *b)
Add a benchmark to this registry.
static void basic_run(int argc, const char *argv[])
Basic implementation of a main function that runs all benchmarks linked into the program.
static Registry & get()
Get the static instance of the registry.
Collect timings for one task.
Definition benchmark.h:20