-
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Juan Cruz Viotti <[email protected]>
- Loading branch information
Showing
5 changed files
with
133 additions
and
121 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
#include <benchmark/benchmark.h> | ||
|
||
#include <cassert> // assert | ||
|
||
#include <sourcemeta/jsontoolkit/json.h> | ||
#include <sourcemeta/jsontoolkit/jsonschema.h> | ||
|
||
static void Evaluator_Draft6_Property_Names(benchmark::State &state) { | ||
const sourcemeta::jsontoolkit::JSON schema{ | ||
sourcemeta::jsontoolkit::parse(R"JSON({ | ||
"$schema": "http://json-schema.org/draft-06/schema#", | ||
"propertyNames": { | ||
"minLength": 2 | ||
} | ||
})JSON")}; | ||
|
||
const sourcemeta::jsontoolkit::JSON instance{ | ||
sourcemeta::jsontoolkit::parse(R"JSON({ | ||
"aa": true, | ||
"bb": true, | ||
"cc": true, | ||
"dd": true, | ||
"ee": true, | ||
"ff": true, | ||
"gg": true, | ||
"hh": true, | ||
"ii": true, | ||
"jj": true, | ||
"kk": true, | ||
"ll": true, | ||
"mm": true, | ||
"nn": true, | ||
"oo": true, | ||
"pp": true, | ||
"qq": true, | ||
"rr": true, | ||
"ss": true, | ||
"tt": true, | ||
"uu": true, | ||
"vv": true, | ||
"ww": true, | ||
"xx": true, | ||
"yy": true, | ||
"zz": true | ||
})JSON")}; | ||
|
||
const auto schema_template{sourcemeta::jsontoolkit::compile( | ||
schema, sourcemeta::jsontoolkit::default_schema_walker, | ||
sourcemeta::jsontoolkit::official_resolver, | ||
sourcemeta::jsontoolkit::default_schema_compiler)}; | ||
for (auto _ : state) { | ||
auto result{sourcemeta::jsontoolkit::evaluate(schema_template, instance)}; | ||
assert(result); | ||
benchmark::DoNotOptimize(result); | ||
} | ||
} | ||
|
||
BENCHMARK(Evaluator_Draft6_Property_Names); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
#include <benchmark/benchmark.h> | ||
|
||
#include <cassert> // assert | ||
|
||
#include <sourcemeta/jsontoolkit/json.h> | ||
#include <sourcemeta/jsontoolkit/jsonschema.h> | ||
|
||
static void Evaluator_Draft7_If_Then_Else(benchmark::State &state) { | ||
const sourcemeta::jsontoolkit::JSON schema{ | ||
sourcemeta::jsontoolkit::parse(R"JSON({ | ||
"$schema": "http://json-schema.org/draft-07/schema#", | ||
"if": { | ||
"type": "string" | ||
}, | ||
"then": { | ||
"if": { "minLength": 2 }, | ||
"then": { "maxLength": 5 }, | ||
"else": { "maxLength": 3 } | ||
}, | ||
"else": { | ||
"if": { "type": "integer" }, | ||
"then": { "minimum": 4 }, | ||
"else": { "maxProperties": 4 } | ||
} | ||
})JSON")}; | ||
|
||
const sourcemeta::jsontoolkit::JSON instance{"foo"}; | ||
|
||
const auto schema_template{sourcemeta::jsontoolkit::compile( | ||
schema, sourcemeta::jsontoolkit::default_schema_walker, | ||
sourcemeta::jsontoolkit::official_resolver, | ||
sourcemeta::jsontoolkit::default_schema_compiler)}; | ||
for (auto _ : state) { | ||
auto result{sourcemeta::jsontoolkit::evaluate(schema_template, instance)}; | ||
assert(result); | ||
benchmark::DoNotOptimize(result); | ||
} | ||
} | ||
|
||
BENCHMARK(Evaluator_Draft7_If_Then_Else); |