From c54e4a7ababec68b188eee160974048f099492bc Mon Sep 17 00:00:00 2001 From: Daniel Lemire Date: Mon, 22 Dec 2025 16:05:51 -0500 Subject: [PATCH] updating the deps --- benchmarks/CMakeLists.txt | 2 +- benchmarks/bench_ip.cpp | 35 +++++------------------------------ benchmarks/benchmark.cpp | 10 +++++----- 3 files changed, 11 insertions(+), 36 deletions(-) diff --git a/benchmarks/CMakeLists.txt b/benchmarks/CMakeLists.txt index 4e22c9e..cfa48b8 100644 --- a/benchmarks/CMakeLists.txt +++ b/benchmarks/CMakeLists.txt @@ -3,7 +3,7 @@ include(FetchContent) FetchContent_Declare( counters GIT_REPOSITORY https://github.com/lemire/counters.git - GIT_TAG v1.0.4 + GIT_TAG v2.0.0 ) FetchContent_MakeAvailable(counters) diff --git a/benchmarks/bench_ip.cpp b/benchmarks/bench_ip.cpp index 33b2c64..782358e 100644 --- a/benchmarks/bench_ip.cpp +++ b/benchmarks/bench_ip.cpp @@ -1,4 +1,4 @@ -#include "counters/event_counter.h" +#include "counters/bench.h" #include "fast_float/fast_float.h" #include #include @@ -8,39 +8,14 @@ #include #include #include -event_collector collector; - -template -event_aggregate bench(const function_type &function, size_t min_repeat = 10, - size_t min_time_ns = 1000000000, - size_t max_repeat = 1000000) { - event_aggregate aggregate{}; - size_t N = min_repeat; - if (N == 0) { - N = 1; - } - for (size_t i = 0; i < N; i++) { - std::atomic_thread_fence(std::memory_order_acquire); - collector.start(); - function(); - std::atomic_thread_fence(std::memory_order_release); - event_count allocate_count = collector.end(); - aggregate << allocate_count; - if ((i + 1 == N) && (aggregate.total_elapsed_ns() < min_time_ns) && - (N < max_repeat)) { - N *= 10; - } - } - return aggregate; -} void pretty_print(size_t volume, size_t bytes, std::string name, - event_aggregate agg) { + counters::event_aggregate agg) { printf("%-40s : ", name.c_str()); printf(" %5.2f GB/s ", bytes / agg.fastest_elapsed_ns()); printf(" %5.1f Ma/s ", volume * 1000.0 / agg.fastest_elapsed_ns()); printf(" %5.2f ns/d ", agg.fastest_elapsed_ns() / volume); - if (collector.has_events()) { + if (counters::event_collector().has_events()) { printf(" %5.2f GHz ", agg.fastest_cycles() / agg.fastest_elapsed_ns()); printf(" %5.2f c/d ", agg.fastest_cycles() / volume); printf(" %5.2f i/d ", agg.fastest_instructions() / volume); @@ -158,7 +133,7 @@ int main() { uint32_t sink = 0; - pretty_print(volume, bytes, "parse_ip_std_fromchars", bench([&]() { + pretty_print(volume, bytes, "parse_ip_std_fromchars", counters::bench([&]() { const char *p = buf.data(); const char *pend = buf.data() + bytes; uint32_t sum = 0; @@ -171,7 +146,7 @@ int main() { sink += sum; })); - pretty_print(volume, bytes, "parse_ip_fastfloat", bench([&]() { + pretty_print(volume, bytes, "parse_ip_fastfloat", counters::bench([&]() { const char *p = buf.data(); const char *pend = buf.data() + bytes; uint32_t sum = 0; diff --git a/benchmarks/benchmark.cpp b/benchmarks/benchmark.cpp index 2cfe15d..d90038e 100644 --- a/benchmarks/benchmark.cpp +++ b/benchmarks/benchmark.cpp @@ -50,14 +50,14 @@ double findmax_fastfloat32(std::vector> &s) { return answer; } -event_collector collector{}; +counters::event_collector collector{}; #ifdef USING_COUNTERS template -std::vector +std::vector time_it_ns(std::vector> &lines, T const &function, size_t repeat) { - std::vector aggregate; + std::vector aggregate; bool printed_bug = false; for (size_t i = 0; i < repeat; i++) { collector.start(); @@ -72,7 +72,7 @@ time_it_ns(std::vector> &lines, T const &function, } void pretty_print(double volume, size_t number_of_floats, std::string name, - std::vector events) { + std::vector events) { double volumeMB = volume / (1024. * 1024.); double average_ns{0}; double min_ns{DBL_MAX}; @@ -84,7 +84,7 @@ void pretty_print(double volume, size_t number_of_floats, std::string name, double branches_avg{0}; double branch_misses_min{0}; double branch_misses_avg{0}; - for (event_count e : events) { + for (counters::event_count e : events) { double ns = e.elapsed_ns(); average_ns += ns; min_ns = min_ns < ns ? min_ns : ns;