JayBeams  0.1
Another project to have fun coding.
microbenchmark_config.cpp
Go to the documentation of this file.
2 
3 namespace jb {
4 namespace testing {
5 /**
6  * Define the default values for a microbenchmark config.
7  *
8  * This is an experiment in how to write highly-configurable classes
9  * for JayBeams. The intention is that any configuration parameter
10  * can be set using these rules:
11  *
12  * -# if the configuration is set in the command-line, use the
13  * command-line value, otherwise
14  * -# if the configuration is set in the configuration file, use the
15  * value in the configuration file, otherwise
16  * -# if the program was compiled with a special setting for the
17  * default value, use that setting, otherwise
18  * -# use whatever default was chosen by the developer.
19  *
20  * The configuration files themselves are found using a series of
21  * rules (TBD).
22  *
23  * What I would want is that each component can define its own config
24  * class, and the main program *choses* which ones become command-line
25  * arguments.
26  */
27 namespace defaults {
28 
29 #ifndef JB_DEFAULTS_microbenchmark_warmup_iterations
30 #define JB_DEFAULTS_microbenchmark_warmup_iterations 100
31 #endif
32 
33 #ifndef JB_DEFAULTS_microbenchmark_iterations
34 #define JB_DEFAULTS_microbenchmark_iterations 1000
35 #endif
36 
37 #ifndef JB_DEFAULTS_microbenchmark_size
38 #define JB_DEFAULTS_microbenchmark_size 0
39 #endif
40 
41 #ifndef JB_DEFAULTS_microbenchmark_verbose
42 #define JB_DEFAULTS_microbenchmark_verbose false
43 #endif
44 
45 #ifndef JB_DEFAULTS_microbenchmark_reconfigure_thread
46 #define JB_DEFAULTS_microbenchmark_reconfigure_thread true
47 #endif
48 
54 
55 } // namespace defaults
56 
59  desc("warmup-iterations")
60  .help("The number of warmup iterations in the benchmark."),
62  , iterations(
63  desc("iterations")
64  .help("Number of iterations to run for a fixed size."),
65  this, defaults::iterations)
66  , size(
67  desc("size").help(
68  "If set (and not zero) control the size of the test."),
69  this, defaults::size)
70  , verbose(
71  desc("verbose").help(
72  "If true, dump the results of every test to stdout for"
73  " statistical analysis."),
74  this, defaults::verbose)
75  , test_case(
76  desc("test-case")
77  .help("Some microbenchmarks test completely different "
78  "configurations"
79  ", settings, or even different algorithms for the "
80  "same problem."
81  " Use this option to configure such benchmarks"
82  ", most microbenchmarks will ignore it."),
83  this)
85  desc("reconfigure-thread")
86  .help("If set reconfigure the main thread scheduling parameters"
87  "before running the benchmark. "
88  "The actual scheduling parameters are configured via the "
89  "--thread option. Unsetting this flag is useful when "
90  "testing "
91  "with external scheduling parameter settings, e.g. chrt(1) "
92  "and taskset(1)."),
94  , thread(
95  desc("thread", "thread")
96  .help("Configure how the main thread scheduling parameters are "
97  "set before running the benchmark. "
98  "By default we attempt to run the test in the FIFO "
99  "scheduling class, at the maximum allowable priority."),
100  this, thread_config().scheduler("FIFO").priority("MAX"))
101  , prefix(
102  desc("prefix").help(
103  "Define the prefix for the detailed results output."
104  " Often microbenchmark results are further analyzed with"
105  " tools such as R or Python scripts, in such cases prefixing"
106  " the output with the attributes of the test (size, test-case,"
107  " system configuration, etc) can make it easier to mix the"
108  " output from multiple microbenchmarks into a single result."
109  " It is common, but not required, for these prefixes to be"
110  " a comma-separated list of values."),
111  this) {
112 }
113 
114 } // namespace testing
115 } // namespace jb
Define defaults for program parameters.
#define JB_DEFAULTS_microbenchmark_size
#define JB_DEFAULTS_microbenchmark_reconfigure_thread
#define JB_DEFAULTS_microbenchmark_warmup_iterations
#define JB_DEFAULTS_microbenchmark_verbose
Hold the configuration to initialize threads.
The top-level namespace for the JayBeams library.
Definition: as_hhmmss.hpp:7
#define JB_DEFAULTS_microbenchmark_iterations