From ec545ed486600df2c1d45dbc94a7b8928867fa68 Mon Sep 17 00:00:00 2001 From: Juan Cruz Viotti Date: Mon, 25 Nov 2024 13:51:34 -0400 Subject: [PATCH] Add a Helm Chart Lock example schema/instance to the benchmark (#227) Signed-off-by: Juan Cruz Viotti --- benchmark/evaluator_draft7.cc | 23 ++++++++++ .../instances/draft7_helm_chart_lock_1.json | 26 +++++++++++ benchmark/schemas/draft7_helm_chart_lock.json | 43 +++++++++++++++++++ 3 files changed, 92 insertions(+) create mode 100644 benchmark/instances/draft7_helm_chart_lock_1.json create mode 100644 benchmark/schemas/draft7_helm_chart_lock.json diff --git a/benchmark/evaluator_draft7.cc b/benchmark/evaluator_draft7.cc index 87a5444d..edc8d6bc 100644 --- a/benchmark/evaluator_draft7.cc +++ b/benchmark/evaluator_draft7.cc @@ -64,5 +64,28 @@ static void Evaluator_Draft7_Vercel_1(benchmark::State &state) { } } +static void Evaluator_Draft7_Helm_Chart_Lock_1(benchmark::State &state) { + const auto schema{sourcemeta::jsontoolkit::from_file( + std::filesystem::path{CURRENT_DIRECTORY} / "schemas" / + "draft7_helm_chart_lock.json")}; + + const auto instance{sourcemeta::jsontoolkit::from_file( + std::filesystem::path{CURRENT_DIRECTORY} / "instances" / + "draft7_helm_chart_lock_1.json")}; + + const auto schema_template{sourcemeta::blaze::compile( + schema, sourcemeta::jsontoolkit::default_schema_walker, + sourcemeta::jsontoolkit::official_resolver, + sourcemeta::blaze::default_schema_compiler)}; + sourcemeta::blaze::EvaluationContext context; + for (auto _ : state) { + auto result{ + sourcemeta::blaze::evaluate(schema_template, instance, context)}; + assert(result); + benchmark::DoNotOptimize(result); + } +} + BENCHMARK(Evaluator_Draft7_If_Then_Else); BENCHMARK(Evaluator_Draft7_Vercel_1); +BENCHMARK(Evaluator_Draft7_Helm_Chart_Lock_1); diff --git a/benchmark/instances/draft7_helm_chart_lock_1.json b/benchmark/instances/draft7_helm_chart_lock_1.json new file mode 100644 index 00000000..ace8b752 --- /dev/null +++ b/benchmark/instances/draft7_helm_chart_lock_1.json @@ -0,0 +1,26 @@ +{ + "dependencies": [ + { + "name": "memcached", + "repository": "https://charts.bitnami.com/bitnami", + "version": "5.9.0" + }, + { + "name": "mysql", + "repository": "https://charts.bitnami.com/bitnami", + "version": "6.14.10" + }, + { + "name": "postgresql", + "repository": "https://charts.bitnami.com/bitnami", + "version": "10.3.17" + }, + { + "name": "mariadb", + "repository": "https://charts.bitnami.com/bitnami", + "version": "9.3.6" + } + ], + "digest": "sha256:157d6244f0fac36b70be1aecfed8811037504d4e3a1060f50688e93531174040", + "generated": "2021-12-23T14:00:42.29198548Z" +} diff --git a/benchmark/schemas/draft7_helm_chart_lock.json b/benchmark/schemas/draft7_helm_chart_lock.json new file mode 100644 index 00000000..69fc0f92 --- /dev/null +++ b/benchmark/schemas/draft7_helm_chart_lock.json @@ -0,0 +1,43 @@ +{ + "$schema": "http://json-schema.org/draft-07/schema#", + "type": "object", + "required": [ + "generated", + "digest", + "dependencies" + ], + "properties": { + "dependencies": { + "type": "array", + "items": { + "type": "object", + "required": [ + "name", + "version", + "repository" + ], + "properties": { + "name": { + "type": "string" + }, + "repository": { + "type": "string", + "format": "uri" + }, + "version": { + "type": "string" + } + }, + "additionalProperties": false + } + }, + "digest": { + "type": "string" + }, + "generated": { + "type": "string", + "format": "date-time" + } + }, + "additionalProperties": false +}