Decouple parser from CommitRequest
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
#include "commit_request.hpp"
|
||||
#include "json_commit_request_parser.hpp"
|
||||
#include "test_data.hpp"
|
||||
|
||||
#include <iostream>
|
||||
@@ -468,10 +469,12 @@ int main() {
|
||||
|
||||
simple_bench.run("WeaselDB Parser", [&] {
|
||||
CommitRequest request;
|
||||
JsonCommitRequestParser parser;
|
||||
std::string mutable_json = SIMPLE_JSON;
|
||||
bool result = request.parse_json(mutable_json.data(), mutable_json.size());
|
||||
bool result =
|
||||
parser.parse(request, mutable_json.data(), mutable_json.size());
|
||||
ankerl::nanobench::doNotOptimizeAway(result);
|
||||
ankerl::nanobench::doNotOptimizeAway(request.is_parse_complete());
|
||||
ankerl::nanobench::doNotOptimizeAway(request.leader_id());
|
||||
});
|
||||
|
||||
simple_bench.run("nlohmann/json + validation", [&] {
|
||||
@@ -545,10 +548,12 @@ int main() {
|
||||
|
||||
medium_bench.run("WeaselDB Parser", [&] {
|
||||
CommitRequest request;
|
||||
JsonCommitRequestParser parser;
|
||||
std::string mutable_json = MEDIUM_JSON;
|
||||
bool result = request.parse_json(mutable_json.data(), mutable_json.size());
|
||||
bool result =
|
||||
parser.parse(request, mutable_json.data(), mutable_json.size());
|
||||
ankerl::nanobench::doNotOptimizeAway(result);
|
||||
ankerl::nanobench::doNotOptimizeAway(request.is_parse_complete());
|
||||
ankerl::nanobench::doNotOptimizeAway(request.leader_id());
|
||||
});
|
||||
|
||||
medium_bench.run("nlohmann/json + validation", [&] {
|
||||
@@ -622,10 +627,12 @@ int main() {
|
||||
|
||||
complex_bench.run("WeaselDB Parser", [&] {
|
||||
CommitRequest request;
|
||||
JsonCommitRequestParser parser;
|
||||
std::string mutable_json = COMPLEX_JSON;
|
||||
bool result = request.parse_json(mutable_json.data(), mutable_json.size());
|
||||
bool result =
|
||||
parser.parse(request, mutable_json.data(), mutable_json.size());
|
||||
ankerl::nanobench::doNotOptimizeAway(result);
|
||||
ankerl::nanobench::doNotOptimizeAway(request.is_parse_complete());
|
||||
ankerl::nanobench::doNotOptimizeAway(request.leader_id());
|
||||
});
|
||||
|
||||
complex_bench.run("nlohmann/json + validation", [&] {
|
||||
@@ -703,11 +710,12 @@ int main() {
|
||||
|
||||
large_bench.run("WeaselDB Parser (" + bench_name + ")", [&] {
|
||||
CommitRequest request;
|
||||
JsonCommitRequestParser parser;
|
||||
std::string mutable_json = large_json;
|
||||
bool result =
|
||||
request.parse_json(mutable_json.data(), mutable_json.size());
|
||||
parser.parse(request, mutable_json.data(), mutable_json.size());
|
||||
ankerl::nanobench::doNotOptimizeAway(result);
|
||||
ankerl::nanobench::doNotOptimizeAway(request.is_parse_complete());
|
||||
ankerl::nanobench::doNotOptimizeAway(request.leader_id());
|
||||
});
|
||||
|
||||
large_bench.run("nlohmann/json + validation (" + bench_name + ")", [&] {
|
||||
@@ -784,8 +792,10 @@ int main() {
|
||||
|
||||
memory_bench.run("WeaselDB Parser (arena allocation)", [&] {
|
||||
CommitRequest request;
|
||||
JsonCommitRequestParser parser;
|
||||
std::string mutable_json = COMPLEX_JSON;
|
||||
bool result = request.parse_json(mutable_json.data(), mutable_json.size());
|
||||
bool result =
|
||||
parser.parse(request, mutable_json.data(), mutable_json.size());
|
||||
ankerl::nanobench::doNotOptimizeAway(result);
|
||||
ankerl::nanobench::doNotOptimizeAway(request.total_allocated());
|
||||
ankerl::nanobench::doNotOptimizeAway(request.used_bytes());
|
||||
@@ -833,16 +843,17 @@ int main() {
|
||||
|
||||
reuse_bench.run("WeaselDB Parser (reset)", [&] {
|
||||
static CommitRequest request;
|
||||
static JsonCommitRequestParser parser;
|
||||
|
||||
std::string mutable_json1 = SIMPLE_JSON;
|
||||
bool result1 =
|
||||
request.parse_json(mutable_json1.data(), mutable_json1.size());
|
||||
parser.parse(request, mutable_json1.data(), mutable_json1.size());
|
||||
|
||||
request.reset();
|
||||
|
||||
std::string mutable_json2 = MEDIUM_JSON;
|
||||
bool result2 =
|
||||
request.parse_json(mutable_json2.data(), mutable_json2.size());
|
||||
parser.parse(request, mutable_json2.data(), mutable_json2.size());
|
||||
|
||||
ankerl::nanobench::doNotOptimizeAway(result1);
|
||||
ankerl::nanobench::doNotOptimizeAway(result2);
|
||||
|
||||
Reference in New Issue
Block a user