1 #ifndef WREPORT_BENCHMARK_H 2 #define WREPORT_BENCHMARK_H 14 #include <sys/resource.h> 28 Task(
const std::string& name) : name(name) {}
32 Task& operator=(
const Task&) =
delete;
61 if (task == o.task)
return *
this;
62 if (task)
delete task;
75 struct timespec time_at_start;
76 struct timespec time_at_end;
77 struct rusage res_at_start;
78 struct rusage res_at_end;
89 unsigned times_run = 0;
102 virtual void start_benchmark(
const Benchmark& b) = 0;
103 virtual void end_benchmark(
const Benchmark& b) = 0;
105 virtual void start_timeit(
const Timeit& t) = 0;
106 virtual void end_timeit(
const Timeit& t) = 0;
108 virtual void start_throughput(
const Throughput& t) = 0;
109 virtual void end_throughput(
const Throughput& t) = 0;
111 virtual void test_failed(
const Task& t, std::exception& e) = 0;
124 std::string cur_benchmark;
126 BasicProgress(
const std::string& prefix, FILE* out=stdout, FILE* err=stderr);
128 void start_benchmark(
const Benchmark& b)
override;
129 void end_benchmark(
const Benchmark& b)
override;
131 void start_timeit(
const Timeit& t)
override;
132 void end_timeit(
const Timeit& t)
override;
134 void start_throughput(
const Throughput& t)
override;
135 void end_throughput(
const Throughput& t)
override;
137 void test_failed(
const Task& t, std::exception& e)
override;
159 virtual void setup() {}
166 void print_timings(
const std::string& prefix);
169 virtual void register_tasks() = 0;
175 std::vector<Benchmark*> benchmarks;
202 static void basic_run(
int argc,
const char* argv[]);
double run_time
How many seconds to run the task to see how many times per second it runs.
Definition: core/benchmark.h:88
std::string name
Name of this benchmark.
Definition: core/benchmark.h:147
virtual void run_once()=0
Run the task once.
Basic progress implementation writing progress information to the given output stream.
Definition: core/benchmark.h:119
Copyright (C) 2008–2010 ARPA-SIM urpsim@smr.arpa.emr.it
Definition: cmdline.h:17
Collect all existing benchmarks.
Definition: core/benchmark.h:173
Base class for all benchmarks.
Definition: core/benchmark.h:144
virtual void teardown()
Clean up after the task has been measured.
Definition: core/benchmark.h:47
Definition: core/benchmark.h:71
virtual void setup()
Set up the environment for running run_once()
Definition: core/benchmark.h:36
One task to be measured.
Definition: core/benchmark.h:22
Definition: core/benchmark.h:52
Definition: core/benchmark.h:85
std::vector< Throughput > throughput_tasks
Tasks for which we time their throughput.
Definition: core/benchmark.h:153
unsigned repetitions
How many times to repeat the task for measuring how long it takes.
Definition: core/benchmark.h:74
std::vector< Timeit > timeit_tasks
Tasks for which we time their duration.
Definition: core/benchmark.h:150
Notify of progress during benchmark execution.
Definition: core/benchmark.h:98