Last change
on this file was d17cf8c, checked in by Vojtech Horky <vojtech.horky@…>, 6 years ago |
hbench: remove global state
Move benchmark parameters into a benchmark environment structure that is
passed to each benchmark.
|
-
Property mode
set to
100644
|
File size:
1.4 KB
|
Rev | Line | |
---|
[fe656783] | 1 | /** @addtogroup hbench hbench
|
---|
[94ebebf] | 2 | * @brief User space benchmarks
|
---|
[d230358] | 3 | * @ingroup apps
|
---|
[a362c16] | 4 | *
|
---|
| 5 | * @details
|
---|
| 6 | *
|
---|
| 7 | * To add a new benchmark, you need to implement the actual benchmarking
|
---|
| 8 | * code and register it.
|
---|
| 9 | *
|
---|
| 10 | * Registration is done by adding
|
---|
| 11 | * <code>extern benchmark_t bench_YOUR_NAME</code> reference to benchlist.h
|
---|
| 12 | * and by adding it to the array in benchlist.c.
|
---|
| 13 | *
|
---|
| 14 | * The actual benchmark should reside in a separate file (see malloc/malloc1.c
|
---|
| 15 | * for example) and has to (at least) declare one function (the actual
|
---|
| 16 | * benchmark) and fill-in the benchmark_t structure.
|
---|
| 17 | *
|
---|
| 18 | * Fill-in the name of the benchmark, its description and a reference to the
|
---|
| 19 | * benchmark function to the benchmark_t.
|
---|
| 20 | *
|
---|
[d17cf8c] | 21 | * The benchmarking function has to accept trhee arguments:
|
---|
| 22 | * @li bench_env_t: benchmark environment configuration
|
---|
[e7f9a09] | 23 | * @li bench_run_t: call bench_run_start and bench_run_stop around the
|
---|
[ebb0835] | 24 | * actual benchmarking code
|
---|
[a362c16] | 25 | * @li uint64_t: size of the workload - typically number of inner loops in
|
---|
| 26 | * your benchmark (used to self-calibrate benchmark size)
|
---|
| 27 | *
|
---|
| 28 | * Typically, the structure of the function is following:
|
---|
| 29 | * @code{c}
|
---|
[d17cf8c] | 30 | * static bool runnerconst bench_env_t const *envbench_run_t *run, uint64_t size)
|
---|
[a362c16] | 31 | * {
|
---|
[e7f9a09] | 32 | * bench_run_start(run);
|
---|
[a362c16] | 33 | * for (uint64_t i = 0; i < size; i++) {
|
---|
| 34 | * // measured action
|
---|
[e7f9a09] | 35 | * if (something_fails) {
|
---|
| 36 | * return bench_run_fail(run, "oops: %s (%d)", str_error(rc), rc);
|
---|
| 37 | * }
|
---|
[a362c16] | 38 | * }
|
---|
[e7f9a09] | 39 | * bench_run_stop(run);
|
---|
[a362c16] | 40 | *
|
---|
| 41 | * return true;
|
---|
| 42 | * }
|
---|
| 43 | * @endcode
|
---|
[d230358] | 44 | */
|
---|
Note:
See
TracBrowser
for help on using the repository browser.