Compare to simdjson
This commit is contained in:
@@ -38,5 +38,5 @@ include(CTest)
|
||||
include(doctest)
|
||||
|
||||
add_executable(mytest src/test.cpp)
|
||||
target_link_libraries(mytest PRIVATE doctest nanobench)
|
||||
target_link_libraries(mytest PRIVATE doctest nanobench simdjson)
|
||||
doctest_discover_tests(mytest)
|
||||
|
||||
31
src/test.cpp
31
src/test.cpp
@@ -9,6 +9,7 @@
|
||||
|
||||
#include <doctest.h>
|
||||
#include <nanobench.h>
|
||||
#include <simdjson.h>
|
||||
|
||||
// This is the JSON grammar in McKeeman Form.
|
||||
|
||||
@@ -904,8 +905,8 @@ TEST_CASE("bench1") {
|
||||
ankerl::nanobench::Bench bench;
|
||||
bench.batch(json.size());
|
||||
bench.unit("byte");
|
||||
bench.run("parser1", [&]() {
|
||||
auto copy = json;
|
||||
bench.run("parser1", [&]() {
|
||||
Parser1 parser(copy.data(), copy.length(), &c, nullptr);
|
||||
bench.doNotOptimizeAway(parser.parse());
|
||||
});
|
||||
@@ -916,9 +917,35 @@ TEST_CASE("bench2") {
|
||||
ankerl::nanobench::Bench bench;
|
||||
bench.batch(json.size());
|
||||
bench.unit("byte");
|
||||
bench.run("parser2", [&]() {
|
||||
auto copy = json;
|
||||
bench.run("parser2", [&]() {
|
||||
Parser2 parser(copy.data(), copy.length(), &c, nullptr);
|
||||
bench.doNotOptimizeAway(parser.parse());
|
||||
});
|
||||
}
|
||||
|
||||
TEST_CASE("bench3") {
|
||||
using namespace simdjson;
|
||||
ankerl::nanobench::Bench bench;
|
||||
bench.batch(json.size());
|
||||
bench.unit("byte");
|
||||
simdjson::padded_string my_padded_data(json.data(), json.size());
|
||||
bench.run("parser3", [&]() {
|
||||
simdjson::dom::parser parser;
|
||||
auto doc = parser.parse(my_padded_data);
|
||||
bench.doNotOptimizeAway(doc);
|
||||
});
|
||||
}
|
||||
|
||||
TEST_CASE("bench4") {
|
||||
using namespace simdjson;
|
||||
ankerl::nanobench::Bench bench;
|
||||
bench.batch(json.size());
|
||||
bench.unit("byte");
|
||||
padded_string my_padded_data(json.data(), json.size());
|
||||
bench.run("parser4", [&]() {
|
||||
ondemand::parser parser;
|
||||
auto doc = parser.iterate(my_padded_data);
|
||||
bench.doNotOptimizeAway(doc);
|
||||
});
|
||||
}
|
||||
|
||||
12
third_party/CMakeLists.txt
vendored
12
third_party/CMakeLists.txt
vendored
@@ -2,9 +2,13 @@
|
||||
add_compile_options(-w)
|
||||
|
||||
add_library(nanobench nanobench.cpp)
|
||||
target_include_directories(
|
||||
nanobench PUBLIC SYSTEM ${CMAKE_CURRENT_LIST_DIR}/include/nanobench)
|
||||
target_include_directories(nanobench SYSTEM
|
||||
PUBLIC ${CMAKE_CURRENT_LIST_DIR}/include/nanobench)
|
||||
|
||||
add_library(doctest doctest.cpp)
|
||||
target_include_directories(
|
||||
doctest PUBLIC SYSTEM ${CMAKE_CURRENT_LIST_DIR}/include/doctest)
|
||||
target_include_directories(doctest SYSTEM
|
||||
PUBLIC ${CMAKE_CURRENT_LIST_DIR}/include/doctest)
|
||||
|
||||
add_library(simdjson simdjson.cpp)
|
||||
target_include_directories(simdjson SYSTEM
|
||||
PUBLIC ${CMAKE_CURRENT_LIST_DIR}/include/simdjson)
|
||||
|
||||
123383
third_party/include/simdjson/simdjson.h
vendored
Normal file
123383
third_party/include/simdjson/simdjson.h
vendored
Normal file
File diff suppressed because it is too large
Load Diff
56252
third_party/simdjson.cpp
vendored
Normal file
56252
third_party/simdjson.cpp
vendored
Normal file
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user