Skip to content

Commit 0dd3149

Browse files
Added UBJSON to the benchmarks
1 parent 70950a3 commit 0dd3149

File tree

6 files changed

+145
-1
lines changed

6 files changed

+145
-1
lines changed

benchmarks/all/canada_read.cpp

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
#include <rfl/json.hpp>
1010
#include <rfl/msgpack.hpp>
1111
#include <rfl/toml.hpp>
12+
#include <rfl/ubjson.hpp>
1213
#include <rfl/yaml.hpp>
1314
#include <type_traits>
1415
#include <vector>
@@ -164,6 +165,30 @@ static void BM_canada_read_reflect_cpp_toml(benchmark::State &state) {
164165
}
165166
BENCHMARK(BM_canada_read_reflect_cpp_toml);
166167

168+
static void BM_canada_read_reflect_cpp_ubjson(benchmark::State &state) {
169+
const auto data = rfl::ubjson::write(load_data());
170+
for (auto _ : state) {
171+
const auto res = rfl::ubjson::read<FeatureCollection>(data);
172+
if (!res) {
173+
std::cout << res.error()->what() << std::endl;
174+
}
175+
}
176+
}
177+
BENCHMARK(BM_canada_read_reflect_cpp_ubjson);
178+
179+
static void BM_canada_read_reflect_cpp_ubjson_without_field_names(
180+
benchmark::State &state) {
181+
const auto data = rfl::ubjson::write<rfl::NoFieldNames>(load_data());
182+
for (auto _ : state) {
183+
const auto res =
184+
rfl::ubjson::read<FeatureCollection, rfl::NoFieldNames>(data);
185+
if (!res) {
186+
std::cout << res.error()->what() << std::endl;
187+
}
188+
}
189+
}
190+
BENCHMARK(BM_canada_read_reflect_cpp_ubjson_without_field_names);
191+
167192
static void BM_canada_read_reflect_cpp_yaml(benchmark::State &state) {
168193
const auto data = rfl::yaml::write(load_data());
169194
for (auto _ : state) {

benchmarks/all/canada_write.cpp

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
#include <rfl/json.hpp>
1010
#include <rfl/msgpack.hpp>
1111
#include <rfl/toml.hpp>
12+
#include <rfl/ubjson.hpp>
1213
#include <rfl/yaml.hpp>
1314
#include <type_traits>
1415
#include <vector>
@@ -149,6 +150,29 @@ static void BM_canada_write_reflect_cpp_toml(benchmark::State &state) {
149150
}
150151
BENCHMARK(BM_canada_write_reflect_cpp_toml);
151152

153+
static void BM_canada_write_reflect_cpp_ubjson(benchmark::State &state) {
154+
const auto data = load_data();
155+
for (auto _ : state) {
156+
const auto output = rfl::ubjson::write(data);
157+
if (output.size() == 0) {
158+
std::cout << "No output" << std::endl;
159+
}
160+
}
161+
}
162+
BENCHMARK(BM_canada_write_reflect_cpp_ubjson);
163+
164+
static void BM_canada_write_reflect_cpp_ubjson_without_field_names(
165+
benchmark::State &state) {
166+
const auto data = load_data();
167+
for (auto _ : state) {
168+
const auto output = rfl::ubjson::write<rfl::NoFieldNames>(data);
169+
if (output.size() == 0) {
170+
std::cout << "No output" << std::endl;
171+
}
172+
}
173+
}
174+
BENCHMARK(BM_canada_write_reflect_cpp_ubjson_without_field_names);
175+
152176
static void BM_canada_write_reflect_cpp_yaml(benchmark::State &state) {
153177
const auto data = load_data();
154178
for (auto _ : state) {

benchmarks/all/licenses_read.cpp

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
#include <rfl/json.hpp>
1010
#include <rfl/msgpack.hpp>
1111
#include <rfl/toml.hpp>
12+
#include <rfl/ubjson.hpp>
1213
#include <rfl/xml.hpp>
1314
#include <rfl/yaml.hpp>
1415
#include <type_traits>
@@ -187,6 +188,29 @@ static void BM_licenses_read_reflect_cpp_toml(benchmark::State &state) {
187188
}
188189
BENCHMARK(BM_licenses_read_reflect_cpp_toml);
189190

191+
static void BM_licenses_read_reflect_cpp_ubjson(benchmark::State &state) {
192+
const auto data = rfl::ubjson::write(load_data());
193+
for (auto _ : state) {
194+
const auto res = rfl::ubjson::read<Licenses>(data);
195+
if (!res) {
196+
std::cout << res.error()->what() << std::endl;
197+
}
198+
}
199+
}
200+
BENCHMARK(BM_licenses_read_reflect_cpp_ubjson);
201+
202+
static void BM_licenses_read_reflect_cpp_ubjson_without_field_names(
203+
benchmark::State &state) {
204+
const auto data = rfl::ubjson::write<rfl::NoFieldNames>(load_data());
205+
for (auto _ : state) {
206+
const auto res = rfl::ubjson::read<Licenses, rfl::NoFieldNames>(data);
207+
if (!res) {
208+
std::cout << res.error()->what() << std::endl;
209+
}
210+
}
211+
}
212+
BENCHMARK(BM_licenses_read_reflect_cpp_ubjson_without_field_names);
213+
190214
static void BM_licenses_read_reflect_cpp_yaml(benchmark::State &state) {
191215
const auto data = rfl::yaml::write(load_data());
192216
for (auto _ : state) {

benchmarks/all/licenses_write.cpp

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
#include <rfl/json.hpp>
1010
#include <rfl/msgpack.hpp>
1111
#include <rfl/toml.hpp>
12+
#include <rfl/ubjson.hpp>
1213
#include <rfl/xml.hpp>
1314
#include <rfl/yaml.hpp>
1415
#include <type_traits>
@@ -176,6 +177,29 @@ static void BM_licenses_write_reflect_cpp_toml(benchmark::State &state) {
176177
}
177178
BENCHMARK(BM_licenses_write_reflect_cpp_toml);
178179

180+
static void BM_licenses_write_reflect_cpp_ubjson(benchmark::State &state) {
181+
const auto data = load_data();
182+
for (auto _ : state) {
183+
const auto output = rfl::ubjson::write(data);
184+
if (output.size() == 0) {
185+
std::cout << "No output" << std::endl;
186+
}
187+
}
188+
}
189+
BENCHMARK(BM_licenses_write_reflect_cpp_ubjson);
190+
191+
static void BM_licenses_write_reflect_cpp_ubjson_without_field_names(
192+
benchmark::State &state) {
193+
const auto data = load_data();
194+
for (auto _ : state) {
195+
const auto output = rfl::ubjson::write<rfl::NoFieldNames>(data);
196+
if (output.size() == 0) {
197+
std::cout << "No output" << std::endl;
198+
}
199+
}
200+
}
201+
BENCHMARK(BM_licenses_write_reflect_cpp_ubjson_without_field_names);
202+
179203
static void BM_licenses_write_reflect_cpp_xml(benchmark::State &state) {
180204
const auto data = load_data();
181205
for (auto _ : state) {

benchmarks/all/person_read.cpp

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,11 @@
99
#include <rfl/json.hpp>
1010
#include <rfl/msgpack.hpp>
1111
#include <rfl/toml.hpp>
12+
#include <rfl/ubjson.hpp>
1213
#include <rfl/xml.hpp>
1314
#include <rfl/yaml.hpp>
1415
#include <type_traits>
1516
#include <vector>
16-
1717
namespace person_read {
1818

1919
// ----------------------------------------------------------------------------
@@ -156,6 +156,29 @@ static void BM_person_read_reflect_cpp_toml(benchmark::State &state) {
156156
}
157157
BENCHMARK(BM_person_read_reflect_cpp_toml);
158158

159+
static void BM_person_read_reflect_cpp_ubjson(benchmark::State &state) {
160+
const auto data = rfl::ubjson::write(load_data());
161+
for (auto _ : state) {
162+
const auto res = rfl::ubjson::read<Person>(data);
163+
if (!res) {
164+
std::cout << res.error()->what() << std::endl;
165+
}
166+
}
167+
}
168+
BENCHMARK(BM_person_read_reflect_cpp_ubjson);
169+
170+
static void BM_person_read_reflect_cpp_ubjson_without_field_names(
171+
benchmark::State &state) {
172+
const auto data = rfl::ubjson::write<rfl::NoFieldNames>(load_data());
173+
for (auto _ : state) {
174+
const auto res = rfl::ubjson::read<Person, rfl::NoFieldNames>(data);
175+
if (!res) {
176+
std::cout << res.error()->what() << std::endl;
177+
}
178+
}
179+
}
180+
BENCHMARK(BM_person_read_reflect_cpp_ubjson_without_field_names);
181+
159182
static void BM_person_read_reflect_cpp_xml(benchmark::State &state) {
160183
const auto data = rfl::xml::write(load_data());
161184
for (auto _ : state) {

benchmarks/all/person_write.cpp

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
#include <rfl/json.hpp>
1010
#include <rfl/msgpack.hpp>
1111
#include <rfl/toml.hpp>
12+
#include <rfl/ubjson.hpp>
1213
#include <rfl/xml.hpp>
1314
#include <rfl/yaml.hpp>
1415
#include <type_traits>
@@ -156,6 +157,29 @@ static void BM_person_write_reflect_cpp_toml(benchmark::State &state) {
156157
}
157158
BENCHMARK(BM_person_write_reflect_cpp_toml);
158159

160+
static void BM_person_write_reflect_cpp_ubjson(benchmark::State &state) {
161+
const auto data = load_data();
162+
for (auto _ : state) {
163+
const auto output = rfl::ubjson::write(data);
164+
if (output.size() == 0) {
165+
std::cout << "No output" << std::endl;
166+
}
167+
}
168+
}
169+
BENCHMARK(BM_person_write_reflect_cpp_ubjson);
170+
171+
static void BM_person_write_reflect_cpp_ubjson_without_field_names(
172+
benchmark::State &state) {
173+
const auto data = load_data();
174+
for (auto _ : state) {
175+
const auto output = rfl::ubjson::write<rfl::NoFieldNames>(data);
176+
if (output.size() == 0) {
177+
std::cout << "No output" << std::endl;
178+
}
179+
}
180+
}
181+
BENCHMARK(BM_person_write_reflect_cpp_ubjson_without_field_names);
182+
159183
static void BM_person_write_reflect_cpp_xml(benchmark::State &state) {
160184
const auto data = load_data();
161185
for (auto _ : state) {

0 commit comments

Comments
 (0)