Skip to content

Commit 406e6e6

Browse files
authored
Merge branch 'main' into disable_reflect_cpp
2 parents af3cd2e + 6c920dc commit 406e6e6

2 files changed

Lines changed: 20 additions & 0 deletions

File tree

benchmarks/src/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,4 +74,5 @@ endif()
7474

7575
target_link_libraries(SerializationBenchmark PRIVATE simdjson-serial nlohmann_json::nlohmann_json simdjson::simdjson)
7676

77+
7778
target_compile_definitions(SerializationTwitterBenchmark PRIVATE JSON_FILE="${CMAKE_CURRENT_SOURCE_DIR}/data/twitter.json")

benchmarks/src/benchmark_serialization.cpp

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@
1010
#include <vector>
1111
#include <format>
1212
#include <atomic>
13+
#include <rfl.hpp>
14+
#include <rfl/json.hpp>
1315
#include "user_profile.hpp"
1416
#include "custom_serializer.h"
1517
#include "nlohmann_user_profile.hpp"
@@ -229,6 +231,22 @@ void bench_nlohmann(std::vector<User> &data) {
229231
);
230232
}
231233

234+
void bench_reflect_cpp(std::vector<User>& data) {
235+
std::string output = rfl::json::write(data);
236+
size_t output_volume = output.size();
237+
printf("# output volume: %zu bytes\n", output_volume);
238+
239+
volatile size_t measured_volume = 0;
240+
pretty_print(
241+
1, output_volume, "bench_reflect_cpp",
242+
bench([&data, &measured_volume, &output_volume] () {
243+
std::string output = rfl::json::write(data);
244+
measured_volume = output.size();
245+
if(measured_volume != output_volume) { printf("mismatch\n"); }
246+
})
247+
);
248+
}
249+
232250

233251
int main() {
234252
constexpr int test_sz = 50'000;
@@ -239,6 +257,7 @@ int main() {
239257
bench_nlohmann(test_data);
240258
bench_custom(test_data);
241259
bench_fast_simpler(test_data);
260+
bench_reflect_cpp(test_data);
242261

243262
return EXIT_SUCCESS;
244263
}

0 commit comments

Comments
 (0)