Add bench_ondemand_largerandom to check theory about executable format
This commit is contained in:
parent
e7e09e444c
commit
dfc510f009
|
@ -1,13 +1,15 @@
|
||||||
include_directories( . linux )
|
include_directories( . linux )
|
||||||
link_libraries(simdjson-windows-headers test-data)
|
link_libraries(simdjson-windows-headers test-data)
|
||||||
|
|
||||||
|
# bench_sax links against the source
|
||||||
if (TARGET benchmark::benchmark)
|
if (TARGET benchmark::benchmark)
|
||||||
add_executable(bench_sax bench_sax.cpp)
|
add_executable(bench_sax bench_sax.cpp)
|
||||||
target_link_libraries(bench_sax PRIVATE simdjson-internal-flags simdjson-include-source benchmark::benchmark)
|
target_link_libraries(bench_sax PRIVATE simdjson-internal-flags simdjson-include-source benchmark::benchmark)
|
||||||
endif (TARGET benchmark::benchmark)
|
endif (TARGET benchmark::benchmark)
|
||||||
|
|
||||||
|
# Everything else links against simdjson proper
|
||||||
link_libraries(simdjson simdjson-flags)
|
link_libraries(simdjson simdjson-flags)
|
||||||
|
|
||||||
add_executable(benchfeatures benchfeatures.cpp)
|
add_executable(benchfeatures benchfeatures.cpp)
|
||||||
add_executable(get_corpus_benchmark get_corpus_benchmark.cpp)
|
add_executable(get_corpus_benchmark get_corpus_benchmark.cpp)
|
||||||
add_executable(perfdiff perfdiff.cpp)
|
add_executable(perfdiff perfdiff.cpp)
|
||||||
|
@ -42,6 +44,7 @@ endif()
|
||||||
|
|
||||||
if (TARGET benchmark::benchmark)
|
if (TARGET benchmark::benchmark)
|
||||||
link_libraries(benchmark::benchmark)
|
link_libraries(benchmark::benchmark)
|
||||||
|
add_subdirectory(largerandom)
|
||||||
add_executable(bench_parse_call bench_parse_call.cpp)
|
add_executable(bench_parse_call bench_parse_call.cpp)
|
||||||
add_executable(bench_dom_api bench_dom_api.cpp)
|
add_executable(bench_dom_api bench_dom_api.cpp)
|
||||||
add_executable(bench_ondemand bench_ondemand.cpp)
|
add_executable(bench_ondemand bench_ondemand.cpp)
|
||||||
|
|
|
@ -0,0 +1,4 @@
|
||||||
|
if (TARGET benchmark::benchmark)
|
||||||
|
link_libraries(benchmark::benchmark)
|
||||||
|
add_executable(bench_ondemand_largerandom bench_ondemand_largerandom.cpp)
|
||||||
|
endif()
|
|
@ -0,0 +1,14 @@
|
||||||
|
#include "simdjson.h"
|
||||||
|
#include <iostream>
|
||||||
|
#include <sstream>
|
||||||
|
#include <random>
|
||||||
|
#include <vector>
|
||||||
|
SIMDJSON_PUSH_DISABLE_ALL_WARNINGS
|
||||||
|
#include <benchmark/benchmark.h>
|
||||||
|
SIMDJSON_POP_DISABLE_WARNINGS
|
||||||
|
|
||||||
|
#define BENCHMARK_NO_DOM
|
||||||
|
|
||||||
|
#include "largerandom/ondemand.h"
|
||||||
|
|
||||||
|
BENCHMARK_MAIN();
|
|
@ -32,38 +32,6 @@ simdjson_really_inline bool Dom::Run(const padded_string &json) {
|
||||||
|
|
||||||
BENCHMARK_TEMPLATE(LargeRandom, Dom);
|
BENCHMARK_TEMPLATE(LargeRandom, Dom);
|
||||||
|
|
||||||
namespace sum {
|
|
||||||
|
|
||||||
class Dom {
|
|
||||||
public:
|
|
||||||
simdjson_really_inline bool Run(const padded_string &json);
|
|
||||||
|
|
||||||
simdjson_really_inline my_point &Result() { return sum; }
|
|
||||||
simdjson_really_inline size_t ItemCount() { return count; }
|
|
||||||
|
|
||||||
private:
|
|
||||||
dom::parser parser{};
|
|
||||||
my_point sum{};
|
|
||||||
size_t count{};
|
|
||||||
};
|
|
||||||
|
|
||||||
simdjson_really_inline bool Dom::Run(const padded_string &json) {
|
|
||||||
sum = { 0, 0, 0 };
|
|
||||||
count = 0;
|
|
||||||
|
|
||||||
for (auto coord : parser.parse(json)) {
|
|
||||||
sum.x += double(coord["x"]);
|
|
||||||
sum.y += double(coord["y"]);
|
|
||||||
sum.z += double(coord["z"]);
|
|
||||||
count++;
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
BENCHMARK_TEMPLATE(LargeRandomSum, Dom);
|
|
||||||
|
|
||||||
} // namespace sum
|
|
||||||
} // namespace largerandom
|
} // namespace largerandom
|
||||||
|
|
||||||
#endif // SIMDJSON_EXCEPTIONS
|
#endif // SIMDJSON_EXCEPTIONS
|
|
@ -48,45 +48,6 @@ simdjson_really_inline bool Iter::Run(const padded_string &json) {
|
||||||
|
|
||||||
BENCHMARK_TEMPLATE(LargeRandom, Iter);
|
BENCHMARK_TEMPLATE(LargeRandom, Iter);
|
||||||
|
|
||||||
|
|
||||||
namespace sum {
|
|
||||||
|
|
||||||
class Iter {
|
|
||||||
public:
|
|
||||||
simdjson_really_inline bool Run(const padded_string &json);
|
|
||||||
|
|
||||||
simdjson_really_inline my_point &Result() { return sum; }
|
|
||||||
simdjson_really_inline size_t ItemCount() { return count; }
|
|
||||||
|
|
||||||
private:
|
|
||||||
ondemand::parser parser{};
|
|
||||||
my_point sum{};
|
|
||||||
size_t count{};
|
|
||||||
};
|
|
||||||
|
|
||||||
simdjson_really_inline bool Iter::Run(const padded_string &json) {
|
|
||||||
sum = {0,0,0};
|
|
||||||
count = 0;
|
|
||||||
|
|
||||||
auto iter = parser.iterate_raw(json).value();
|
|
||||||
if (!iter.start_array()) { return false; }
|
|
||||||
do {
|
|
||||||
if (!iter.start_object() || iter.field_key().value() != "x" || iter.field_value()) { return false; }
|
|
||||||
sum.x += iter.consume_double();
|
|
||||||
if (!iter.has_next_field() || iter.field_key().value() != "y" || iter.field_value()) { return false; }
|
|
||||||
sum.y += iter.consume_double();
|
|
||||||
if (!iter.has_next_field() || iter.field_key().value() != "z" || iter.field_value()) { return false; }
|
|
||||||
sum.z += iter.consume_double();
|
|
||||||
if (*iter.advance() != '}') { return false; }
|
|
||||||
count++;
|
|
||||||
} while (iter.has_next_element());
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
BENCHMARK_TEMPLATE(LargeRandomSum, Iter);
|
|
||||||
|
|
||||||
} // namespace sum
|
|
||||||
} // namespace largerandom
|
} // namespace largerandom
|
||||||
|
|
||||||
#endif // SIMDJSON_EXCEPTIONS
|
#endif // SIMDJSON_EXCEPTIONS
|
||||||
|
|
|
@ -8,9 +8,6 @@
|
||||||
|
|
||||||
namespace largerandom {
|
namespace largerandom {
|
||||||
template<typename T> static void LargeRandom(benchmark::State &state);
|
template<typename T> static void LargeRandom(benchmark::State &state);
|
||||||
namespace sum {
|
|
||||||
template<typename T> static void LargeRandomSum(benchmark::State &state);
|
|
||||||
}
|
|
||||||
|
|
||||||
using namespace simdjson;
|
using namespace simdjson;
|
||||||
|
|
||||||
|
@ -59,22 +56,21 @@ simdjson_unused static std::ostream &operator<<(std::ostream &o, const my_point
|
||||||
//
|
//
|
||||||
#include <vector>
|
#include <vector>
|
||||||
#include "event_counter.h"
|
#include "event_counter.h"
|
||||||
|
#ifndef BENCHMARK_NO_DOM
|
||||||
#include "dom.h"
|
#include "dom.h"
|
||||||
|
#endif
|
||||||
#include "json_benchmark.h"
|
#include "json_benchmark.h"
|
||||||
|
|
||||||
namespace largerandom {
|
namespace largerandom {
|
||||||
|
|
||||||
template<typename T> static void LargeRandom(benchmark::State &state) {
|
template<typename T> static void LargeRandom(benchmark::State &state) {
|
||||||
|
#ifdef BENCHMARK_NO_DOM
|
||||||
|
JsonBenchmark<T, T>(state, get_built_json_array());
|
||||||
|
#else
|
||||||
JsonBenchmark<T, Dom>(state, get_built_json_array());
|
JsonBenchmark<T, Dom>(state, get_built_json_array());
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
namespace sum {
|
|
||||||
|
|
||||||
template<typename T> static void LargeRandomSum(benchmark::State &state) {
|
|
||||||
JsonBenchmark<T, Dom>(state, get_built_json_array());
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
} // namespace largerandom
|
} // namespace largerandom
|
||||||
|
|
||||||
#endif // SIMDJSON_EXCEPTIONS
|
#endif // SIMDJSON_EXCEPTIONS
|
||||||
|
|
|
@ -33,39 +33,6 @@ simdjson_really_inline bool OnDemand::Run(const padded_string &json) {
|
||||||
|
|
||||||
BENCHMARK_TEMPLATE(LargeRandom, OnDemand);
|
BENCHMARK_TEMPLATE(LargeRandom, OnDemand);
|
||||||
|
|
||||||
|
|
||||||
namespace sum {
|
|
||||||
|
|
||||||
class OnDemand {
|
|
||||||
public:
|
|
||||||
simdjson_really_inline bool Run(const padded_string &json);
|
|
||||||
simdjson_really_inline my_point &Result() { return sum; }
|
|
||||||
simdjson_really_inline size_t ItemCount() { return count; }
|
|
||||||
|
|
||||||
private:
|
|
||||||
ondemand::parser parser{};
|
|
||||||
my_point sum{};
|
|
||||||
size_t count{};
|
|
||||||
};
|
|
||||||
|
|
||||||
simdjson_really_inline bool OnDemand::Run(const padded_string &json) {
|
|
||||||
sum = {0,0,0};
|
|
||||||
count = 0;
|
|
||||||
|
|
||||||
auto doc = parser.iterate(json);
|
|
||||||
for (ondemand::object coord : doc.get_array()) {
|
|
||||||
sum.x += double(coord.find_field("x"));
|
|
||||||
sum.y += double(coord.find_field("y"));
|
|
||||||
sum.z += double(coord.find_field("z"));
|
|
||||||
count++;
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
BENCHMARK_TEMPLATE(LargeRandomSum, OnDemand);
|
|
||||||
|
|
||||||
} // namespace sum
|
|
||||||
} // namespace largerandom
|
} // namespace largerandom
|
||||||
|
|
||||||
#endif // SIMDJSON_EXCEPTIONS
|
#endif // SIMDJSON_EXCEPTIONS
|
||||||
|
|
Loading…
Reference in New Issue