diff options
author | furszy <matiasfurszyfer@protonmail.com> | 2022-09-22 18:18:18 -0300 |
---|---|---|
committer | furszy <matiasfurszyfer@protonmail.com> | 2022-10-20 10:21:04 -0300 |
commit | 05b8c76232dedf938740e8034c725ac16d32974a (patch) | |
tree | 7c2a10aa8a675e45bff92826b3e1f65ce1bda767 /src/bench/bench.h | |
parent | f1593780b8e3b6adefee08b10d270c5c329f91fe (diff) |
bench: add "priority level" to the benchmark framework
Will allow us to run certain benchmarks while skip
non-prioritized ones in 'make check'.
Diffstat (limited to 'src/bench/bench.h')
-rw-r--r-- | src/bench/bench.h | 20 |
1 files changed, 16 insertions, 4 deletions
diff --git a/src/bench/bench.h b/src/bench/bench.h index 17535e4e81..1f412c9aec 100644 --- a/src/bench/bench.h +++ b/src/bench/bench.h @@ -41,6 +41,16 @@ using ankerl::nanobench::Bench; typedef std::function<void(Bench&)> BenchFunction; +enum PriorityLevel : uint8_t +{ + LOW = 1 << 0, + HIGH = 1 << 2, +}; + +// List priority labels, comma-separated and sorted by increasing priority +std::string ListPriorities(); +uint8_t StringToPriority(const std::string& str); + struct Args { bool is_list_only; bool sanity_check; @@ -49,22 +59,24 @@ struct Args { fs::path output_csv; fs::path output_json; std::string regex_filter; + uint8_t priority; }; class BenchRunner { - typedef std::map<std::string, BenchFunction> BenchmarkMap; + // maps from "name" -> (function, priority_level) + typedef std::map<std::string, std::pair<BenchFunction, PriorityLevel>> BenchmarkMap; static BenchmarkMap& benchmarks(); public: - BenchRunner(std::string name, BenchFunction func); + BenchRunner(std::string name, BenchFunction func, PriorityLevel level); static void RunAll(const Args& args); }; } // namespace benchmark -// BENCHMARK(foo) expands to: benchmark::BenchRunner bench_11foo("foo", foo); +// BENCHMARK(foo) expands to: benchmark::BenchRunner bench_11foo("foo", foo, priority_level); #define BENCHMARK(n) \ - benchmark::BenchRunner PASTE2(bench_, PASTE2(__LINE__, n))(STRINGIZE(n), n); + benchmark::BenchRunner PASTE2(bench_, PASTE2(__LINE__, n))(STRINGIZE(n), n, benchmark::PriorityLevel::HIGH); #endif // BITCOIN_BENCH_BENCH_H |