updating the deps

This commit is contained in:
Daniel Lemire 2025-12-22 16:05:51 -05:00
parent 5304b3d611
commit c54e4a7aba
3 changed files with 11 additions and 36 deletions

View File

@ -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)

View File

@ -1,4 +1,4 @@
#include "counters/event_counter.h"
#include "counters/bench.h"
#include "fast_float/fast_float.h"
#include <charconv>
#include <cstdint>
@ -8,39 +8,14 @@
#include <random>
#include <atomic>
#include <string>
event_collector collector;
template <class function_type>
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;

View File

@ -50,14 +50,14 @@ double findmax_fastfloat32(std::vector<std::basic_string<CharT>> &s) {
return answer;
}
event_collector collector{};
counters::event_collector collector{};
#ifdef USING_COUNTERS
template <class T, class CharT>
std::vector<event_count>
std::vector<counters::event_count>
time_it_ns(std::vector<std::basic_string<CharT>> &lines, T const &function,
size_t repeat) {
std::vector<event_count> aggregate;
std::vector<counters::event_count> aggregate;
bool printed_bug = false;
for (size_t i = 0; i < repeat; i++) {
collector.start();
@ -72,7 +72,7 @@ time_it_ns(std::vector<std::basic_string<CharT>> &lines, T const &function,
}
void pretty_print(double volume, size_t number_of_floats, std::string name,
std::vector<event_count> events) {
std::vector<counters::event_count> 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;