File: runner_base.h

package info (click to toggle)
simdjson 4.3.1-5
  • links: PTS, VCS
  • area: main
  • in suites:
  • size: 31,396 kB
  • sloc: cpp: 195,760; ansic: 20,954; sh: 1,126; python: 885; makefile: 47; ruby: 25; javascript: 13
file content (40 lines) | stat: -rw-r--r-- 1,258 bytes parent folder | download | duplicates (8)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
#pragma once

#include "constants.h"
#include "run_json_benchmark.h"
#include "diff_results.h"

namespace json_benchmark {

//
// Extend this to create a new type of test (e.g. partial_tweets).
//
template<typename I>
struct runner_base {
  /** Run once, before all iterations. */
  simdjson_warn_unused bool setup(benchmark::State &) { return true; }

  /** Run on each iteration. This is what gets benchmarked. */
  simdjson_warn_unused bool run(benchmark::State &state) {
    return implementation.run(state);
  }

  /** Called before each iteration, to clear / set up state. */
  simdjson_warn_unused bool before_run(benchmark::State &state) { return true; }

  /** Called after each iteration, to tear down / massage state. */
  simdjson_warn_unused bool after_run(benchmark::State &) { return true; }

  /** Get the total number of bytes processed in each iteration. Used for metrics like bytes/second. */
  size_t bytes_per_iteration();

  /** Get the total number of documents processed in each iteration. Used for metrics like documents/second. */
  size_t documents_per_iteration();

  /** Get the total number of items processed in each iteration. Used for metrics like items/second. */
  size_t items_per_iteration();

  I implementation{};
};

}