Skip to content

Commit c54e4a7

Browse files
committed
updating the deps
1 parent 5304b3d commit c54e4a7

File tree

3 files changed

+11
-36
lines changed

3 files changed

+11
-36
lines changed

benchmarks/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ include(FetchContent)
33
FetchContent_Declare(
44
counters
55
GIT_REPOSITORY https://github.com/lemire/counters.git
6-
GIT_TAG v1.0.4
6+
GIT_TAG v2.0.0
77
)
88

99
FetchContent_MakeAvailable(counters)

benchmarks/bench_ip.cpp

Lines changed: 5 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#include "counters/event_counter.h"
1+
#include "counters/bench.h"
22
#include "fast_float/fast_float.h"
33
#include <charconv>
44
#include <cstdint>
@@ -8,39 +8,14 @@
88
#include <random>
99
#include <atomic>
1010
#include <string>
11-
event_collector collector;
12-
13-
template <class function_type>
14-
event_aggregate bench(const function_type &function, size_t min_repeat = 10,
15-
size_t min_time_ns = 1000000000,
16-
size_t max_repeat = 1000000) {
17-
event_aggregate aggregate{};
18-
size_t N = min_repeat;
19-
if (N == 0) {
20-
N = 1;
21-
}
22-
for (size_t i = 0; i < N; i++) {
23-
std::atomic_thread_fence(std::memory_order_acquire);
24-
collector.start();
25-
function();
26-
std::atomic_thread_fence(std::memory_order_release);
27-
event_count allocate_count = collector.end();
28-
aggregate << allocate_count;
29-
if ((i + 1 == N) && (aggregate.total_elapsed_ns() < min_time_ns) &&
30-
(N < max_repeat)) {
31-
N *= 10;
32-
}
33-
}
34-
return aggregate;
35-
}
3611

3712
void pretty_print(size_t volume, size_t bytes, std::string name,
38-
event_aggregate agg) {
13+
counters::event_aggregate agg) {
3914
printf("%-40s : ", name.c_str());
4015
printf(" %5.2f GB/s ", bytes / agg.fastest_elapsed_ns());
4116
printf(" %5.1f Ma/s ", volume * 1000.0 / agg.fastest_elapsed_ns());
4217
printf(" %5.2f ns/d ", agg.fastest_elapsed_ns() / volume);
43-
if (collector.has_events()) {
18+
if (counters::event_collector().has_events()) {
4419
printf(" %5.2f GHz ", agg.fastest_cycles() / agg.fastest_elapsed_ns());
4520
printf(" %5.2f c/d ", agg.fastest_cycles() / volume);
4621
printf(" %5.2f i/d ", agg.fastest_instructions() / volume);
@@ -158,7 +133,7 @@ int main() {
158133

159134
uint32_t sink = 0;
160135

161-
pretty_print(volume, bytes, "parse_ip_std_fromchars", bench([&]() {
136+
pretty_print(volume, bytes, "parse_ip_std_fromchars", counters::bench([&]() {
162137
const char *p = buf.data();
163138
const char *pend = buf.data() + bytes;
164139
uint32_t sum = 0;
@@ -171,7 +146,7 @@ int main() {
171146
sink += sum;
172147
}));
173148

174-
pretty_print(volume, bytes, "parse_ip_fastfloat", bench([&]() {
149+
pretty_print(volume, bytes, "parse_ip_fastfloat", counters::bench([&]() {
175150
const char *p = buf.data();
176151
const char *pend = buf.data() + bytes;
177152
uint32_t sum = 0;

benchmarks/benchmark.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -50,14 +50,14 @@ double findmax_fastfloat32(std::vector<std::basic_string<CharT>> &s) {
5050
return answer;
5151
}
5252

53-
event_collector collector{};
53+
counters::event_collector collector{};
5454

5555
#ifdef USING_COUNTERS
5656
template <class T, class CharT>
57-
std::vector<event_count>
57+
std::vector<counters::event_count>
5858
time_it_ns(std::vector<std::basic_string<CharT>> &lines, T const &function,
5959
size_t repeat) {
60-
std::vector<event_count> aggregate;
60+
std::vector<counters::event_count> aggregate;
6161
bool printed_bug = false;
6262
for (size_t i = 0; i < repeat; i++) {
6363
collector.start();
@@ -72,7 +72,7 @@ time_it_ns(std::vector<std::basic_string<CharT>> &lines, T const &function,
7272
}
7373

7474
void pretty_print(double volume, size_t number_of_floats, std::string name,
75-
std::vector<event_count> events) {
75+
std::vector<counters::event_count> events) {
7676
double volumeMB = volume / (1024. * 1024.);
7777
double average_ns{0};
7878
double min_ns{DBL_MAX};
@@ -84,7 +84,7 @@ void pretty_print(double volume, size_t number_of_floats, std::string name,
8484
double branches_avg{0};
8585
double branch_misses_min{0};
8686
double branch_misses_avg{0};
87-
for (event_count e : events) {
87+
for (counters::event_count e : events) {
8888
double ns = e.elapsed_ns();
8989
average_ns += ns;
9090
min_ns = min_ns < ns ? min_ns : ns;

0 commit comments

Comments
 (0)