1 #ifndef DBALLE_CORE_BENCHMARK_H 2 #define DBALLE_CORE_BENCHMARK_H 15 #include <sys/resource.h> 16 #include <dballe/message.h> 17 #include <dballe/file.h> 31 Task& operator=(
const Task&) =
delete;
34 virtual const char* name()
const = 0;
55 std::string task_name;
58 struct timespec time_at_start;
59 struct timespec time_at_end;
60 struct rusage res_at_start;
61 struct rusage res_at_end;
68 std::string task_name;
71 unsigned times_run = 0;
82 virtual void start_timeit(
const Timeit& t) = 0;
83 virtual void end_timeit(
const Timeit& t) = 0;
85 virtual void start_throughput(
const Throughput& t) = 0;
86 virtual void end_throughput(
const Throughput& t) = 0;
88 virtual void test_failed(
const Task& t, std::exception& e) = 0;
103 void start_timeit(
const Timeit& t)
override;
104 void end_timeit(
const Timeit& t)
override;
106 void start_throughput(
const Throughput& t)
override;
107 void end_throughput(
const Throughput& t)
override;
109 void test_failed(
const Task& t, std::exception& e)
override;
132 void timeit(
Task& task,
unsigned repetitions=1);
145 struct Messages :
public std::vector<std::vector<std::shared_ptr<dballe::Message>>>
147 void load(
const std::string& pathname, dballe::Encoding encoding=dballe::Encoding::BUFR,
const char* codec_options=
"accurate");
151 void duplicate(
size_t size,
const Datetime& datetime);
158 bool has(
const std::string& val);
double run_time
How many seconds to run the task to see how many times per second it runs.
Definition: benchmark.h:70
virtual void run_once()=0
Run the task once.
void print_timings()
Print timings to stdout.
Basic progress implementation writing progress information to the given output stream.
Definition: benchmark.h:96
void timeit(Task &task, unsigned repetitions=1)
Run the benchmark and collect timings.
std::shared_ptr< Progress > progress
Progress indicator.
Definition: benchmark.h:119
Base class for all benchmarks.
Definition: benchmark.h:116
Container for parsed messages used for benchmarking.
Definition: benchmark.h:145
virtual void teardown()
Clean up after the task has been measured.
Definition: benchmark.h:48
Definition: benchmark.h:53
virtual void setup()
Set up the environment for running run_once()
Definition: benchmark.h:37
Definition: benchmark.h:154
One task to be measured.
Definition: benchmark.h:25
void throughput(Task &task, double run_time=0.5)
Run the benchmark and collect timings.
Date and time.
Definition: types.h:164
Definition: benchmark.h:66
std::vector< Throughput > throughput_tasks
Tasks for which we time their throughput.
Definition: benchmark.h:125
unsigned repetitions
How many times to repeat the task for measuring how long it takes.
Definition: benchmark.h:57
std::vector< Timeit > timeit_tasks
Tasks for which we time their duration.
Definition: benchmark.h:122
Notify of progress during benchmark execution.
Definition: benchmark.h:78