Theoretica
A C++ numerical and automatic mathematical library
benchmark_structures.h
Go to the documentation of this file.
1 
5 
6 #ifndef CHEBYSHEV_BENCHMARK_STRUCTURES_H
7 #define CHEBYSHEV_BENCHMARK_STRUCTURES_H
8 
9 #include <functional>
10 #include <map>
11 
12 #include "../core/common.h"
13 #include "./generator.h"
14 
15 
16 namespace chebyshev {
17 
18  namespace benchmark {
19 
20 
24 
26  std::string name = "unknown";
27 
29  unsigned int runs = 0;
30 
32  unsigned int iterations = 0;
33 
35  long double totalRuntime = get_nan<long double>();
36 
38  long double averageRuntime = get_nan<long double>();
39 
41  long double stdevRuntime = get_nan<long double>();
42 
44  long double runsPerSecond = get_nan<long double>();
45 
48  bool failed = true;
49 
51  bool quiet = false;
52 
54  std::map<std::string, long double> additionalFields {};
55 
56  };
57 
58 
61  template<typename InputType>
62  using InputGenerator = std::function<InputType(unsigned int)>;
63 
64 
67  template<typename InputType = double>
69 
72 
75 
78 
80  bool quiet = false;
81 
82 
85 
88  benchmark_options(unsigned int runs, unsigned int iterations, bool quiet = false)
90 
94  unsigned int runs,
95  unsigned int iterations,
97  bool quiet = false)
99 
100  };
101 
102  }
103 }
104 
105 #endif
#define CHEBYSHEV_BENCHMARK_ITER
Default number of benchmark iterations.
Definition: common.h:22
#define CHEBYSHEV_BENCHMARK_RUNS
Default number of benchmark runs.
Definition: common.h:27
Input generators for benchmarks.
auto uniform1D(long double a, long double b)
Uniform generator over a domain.
Definition: generator.h:21
void benchmark(const std::string &name, Function func, const std::vector< InputType > &input, unsigned int runs=settings.defaultRuns, bool quiet=false)
Run a benchmark on a generic function, with the given input vector.
Definition: benchmark.h:187
std::function< InputType(unsigned int)> InputGenerator
A function which takes in an index and returns a generated input element.
Definition: benchmark_structures.h:62
std::string string(size_t length)
Generate a random string made of human-readable ASCII characters.
Definition: random.h:102
General namespace of the framework.
Definition: benchmark_structures.h:16
A structure holding the options of a benchmark.
Definition: benchmark_structures.h:68
benchmark_options(unsigned int runs, unsigned int iterations, bool quiet=false)
Construct benchmark options from the number of runs and iterations and whether to print the case to o...
Definition: benchmark_structures.h:88
unsigned int iterations
Number of iterations.
Definition: benchmark_structures.h:74
bool quiet
Whether to print to standard output or not.
Definition: benchmark_structures.h:80
benchmark_options()
Default constructor for benchmark options.
Definition: benchmark_structures.h:84
unsigned int runs
Number of runs (run with the same input values).
Definition: benchmark_structures.h:71
InputGenerator< InputType > inputGenerator
The function to use to generate input for the benchmark.
Definition: benchmark_structures.h:77
benchmark_options(unsigned int runs, unsigned int iterations, InputGenerator< InputType > gen, bool quiet=false)
Construct benchmark options from the number of runs and iterations, the input generator to use and wh...
Definition: benchmark_structures.h:93
Structure holding the results of a benchmark.
Definition: benchmark_structures.h:23
bool quiet
Whether to print to standard output or not.
Definition: benchmark_structures.h:51
long double averageRuntime
Estimated average runtime.
Definition: benchmark_structures.h:38
bool failed
Whether the benchmark failed because an exception was thrown.
Definition: benchmark_structures.h:48
unsigned int runs
Number of runs.
Definition: benchmark_structures.h:29
unsigned int iterations
Number of iterations.
Definition: benchmark_structures.h:32
long double runsPerSecond
Number of runs per second.
Definition: benchmark_structures.h:44
long double totalRuntime
Total runtime over all runs and iterations.
Definition: benchmark_structures.h:35
std::string name
Identifying name of the function or test case.
Definition: benchmark_structures.h:26
std::map< std::string, long double > additionalFields
Additional fields in floating point representation.
Definition: benchmark_structures.h:54
long double stdevRuntime
Sample standard deviation of the runtime.
Definition: benchmark_structures.h:41