Skip to content

Commit 6a267f2

Browse files
author
Daniel Lemire
committed
Merge branch 'disable_reflect_cpp'
2 parents 76b8c78 + e0e598a commit 6a267f2

1 file changed

Lines changed: 2 additions & 40 deletions

File tree

benchmarks/src/benchmark_serialization.cpp

Lines changed: 2 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@
1313
#include "user_profile.hpp"
1414
#include "custom_serializer.h"
1515
#include "nlohmann_user_profile.hpp"
16+
#include "benchmark_helper.hpp"
17+
1618
#if SIMDJSON_BENCH_CPP_REFLECT
1719
#include "benchmark_reflect_serialization.hpp"
1820
#endif
@@ -102,46 +104,6 @@ User generate_random_user() {
102104
return user;
103105
}
104106

105-
event_collector collector;
106-
107-
template <class function_type>
108-
event_aggregate bench(const function_type &function, size_t min_repeat = 10,
109-
size_t min_time_ns = 1000000000,
110-
size_t max_repeat = 100) {
111-
event_aggregate aggregate{};
112-
size_t N = min_repeat;
113-
if (N == 0) {
114-
N = 1;
115-
}
116-
for (size_t i = 0; i < N; i++) {
117-
std::atomic_thread_fence(std::memory_order_acquire);
118-
collector.start();
119-
function();
120-
std::atomic_thread_fence(std::memory_order_release);
121-
event_count allocate_count = collector.end();
122-
aggregate << allocate_count;
123-
if ((i + 1 == N) && (aggregate.total_elapsed_ns() < min_time_ns) &&
124-
(N < max_repeat)) {
125-
N *= 10;
126-
}
127-
}
128-
return aggregate;
129-
}
130-
131-
// Source of the 2 functions below:
132-
// https://github.com/simdutf/simdutf/blob/master/benchmarks/base64/benchmark_base64.cpp
133-
void pretty_print(size_t strings, size_t bytes, std::string name, event_aggregate agg) {
134-
printf("%-60s : ", name.c_str());
135-
printf(" %5.2f MB/s ", bytes * 1000 / agg.elapsed_ns());
136-
printf(" %5.2f Ms/s ", strings * 1000 / agg.elapsed_ns());
137-
if (collector.has_events()) {
138-
printf(" %5.2f GHz ", agg.cycles() / agg.elapsed_ns());
139-
printf(" %5.2f c/b ", agg.cycles() / bytes);
140-
printf(" %5.2f i/b ", agg.instructions() / bytes);
141-
printf(" %5.2f i/c ", agg.instructions() / agg.cycles());
142-
}
143-
printf("\n");
144-
}
145107

146108
void bench_custom(std::vector<User> &data) {
147109
size_t volume = std::accumulate(data.begin(), data.end(), size_t(0), [](size_t a, const User &b) { return a + sizeof(b); });

0 commit comments

Comments
 (0)