Benchmark minify

This commit is contained in:
John Keiser 2020-03-09 09:08:06 -07:00
parent acc7bd79b0
commit 0c190b165c
1 changed files with 15 additions and 0 deletions

View File

@ -1,5 +1,7 @@
#include <benchmark/benchmark.h>
#include "simdjson.h"
#include <sstream>
using namespace simdjson;
using namespace benchmark;
using namespace std;
@ -229,4 +231,17 @@ static void iterator_twitter_image_sizes(State& state) {
}
BENCHMARK(iterator_twitter_image_sizes);
static void print_json(State& state) noexcept {
// Prints the number of results in twitter.json
padded_string json = get_corpus(JSON_TEST_PATH);
document::parser parser;
if (!parser.allocate_capacity(json.length())) { cerr << "allocation failed" << endl; return; }
if (int error = json_parse(json, parser); error != SUCCESS) { cerr << error_message(error) << endl; return; }
for (auto _ : state) {
std::stringstream s;
if (!parser.print_json(s)) { cerr << "print_json failed" << endl; return; }
}
}
BENCHMARK(print_json);
BENCHMARK_MAIN();