Barretenberg
The ZK-SNARK library at the core of Aztec
Loading...
Searching...
No Matches
op_count_google_bench.hpp
Go to the documentation of this file.
1
2#pragma once
3#include <benchmark/benchmark.h>
4
5#ifdef __wasm__
6namespace bb {
7struct GoogleBenchOpCountReporter {
8 GoogleBenchOpCountReporter(::benchmark::State& state)
9 {
10 // unused, we don't have op counts on
11 (void)state;
12 }
13};
14}; // namespace bb
15// require a semicolon to appease formatters
16#define BB_REPORT_OP_COUNT_IN_BENCH(state) (void)0
17#define BB_REPORT_OP_COUNT_BENCH_CANCEL() (void)0
18#else
19#include "op_count.hpp"
20namespace bb {
21// NOLINTNEXTLINE(cppcoreguidelines-special-member-functions)
23 // We allow having a ref member as this only lives inside a function frame
24 ::benchmark::State& state;
25 bool cancelled = false;
26 GoogleBenchOpCountReporter(::benchmark::State& state)
27 : state(state)
28 {
29 // Intent: Clear when we enter the state loop
31 }
33 {
34 // Allow for conditional reporting
35 if (cancelled) {
36 return;
37 }
38 // Intent: Collect results when we exit the state loop
40 state.counters[entry.first] = static_cast<double>(entry.second);
41 }
42 }
43};
44// Allow for integration with google benchmark user-defined counters
45// NOLINTNEXTLINE(cppcoreguidelines-macro-usage)
46#define BB_REPORT_OP_COUNT_IN_BENCH(state) bb::GoogleBenchOpCountReporter __bb_report_op_count_in_bench{ state };
47// NOLINTNEXTLINE(cppcoreguidelines-macro-usage)
48#define BB_REPORT_OP_COUNT_BENCH_CANCEL() __bb_report_op_count_in_bench.cancelled = true;
49}; // namespace bb
50#endif
GlobalOpCountContainer GLOBAL_OP_COUNTS
Definition op_count.cpp:87
Entry point for Barretenberg command-line interface.
GoogleBenchOpCountReporter(::benchmark::State &state)
std::map< std::string, std::size_t > get_aggregate_counts() const
Definition op_count.cpp:44