Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/website-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@ jobs:
-DBLAZE_COMPILER:BOOL=OFF
-DBLAZE_EVALUATOR:BOOL=OFF
-DBLAZE_OUTPUT:BOOL=OFF
-DBLAZE_LINTER:BOOL=OFF
-DBLAZE_TEST:BOOL=OFF
-DBLAZE_CONFIGURATION:BOOL=OFF
-DBLAZE_ALTERSCHEMA:BOOL=OFF
-DBLAZE_TESTS:BOOL=OFF
-DBLAZE_DOCS:BOOL=ON
- run: cmake --build ./build --config Release --target doxygen
2 changes: 1 addition & 1 deletion .github/workflows/website-deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,9 @@ jobs:
-DBLAZE_COMPILER:BOOL=OFF
-DBLAZE_EVALUATOR:BOOL=OFF
-DBLAZE_OUTPUT:BOOL=OFF
-DBLAZE_LINTER:BOOL=OFF
-DBLAZE_TEST:BOOL=OFF
-DBLAZE_CONFIGURATION:BOOL=OFF
-DBLAZE_ALTERSCHEMA:BOOL=OFF
-DBLAZE_TESTS:BOOL=OFF
-DBLAZE_DOCS:BOOL=ON
- run: cmake --build ./build --config Release --target doxygen
Expand Down
18 changes: 9 additions & 9 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@ list(APPEND CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/cmake")
option(BLAZE_COMPILER "Build the Blaze compiler library" ON)
option(BLAZE_EVALUATOR "Build the Blaze evaluator library" ON)
option(BLAZE_OUTPUT "Build the Blaze output formats library" ON)
option(BLAZE_LINTER "Build the Blaze linter rule library" ON)
option(BLAZE_TEST "Build the Blaze test runner library" ON)
option(BLAZE_CONFIGURATION "Build the Blaze configuration file library" ON)
option(BLAZE_ALTERSCHEMA "Build the Blaze alterschema rule library" ON)
option(BLAZE_TESTS "Build the Blaze tests" OFF)
option(BLAZE_BENCHMARK "Build the Blaze benchmarks" OFF)
option(BLAZE_CONTRIB "Build the Blaze contrib programs" OFF)
Expand Down Expand Up @@ -55,10 +55,6 @@ if(BLAZE_OUTPUT)
add_subdirectory(src/output)
endif()

if(BLAZE_LINTER)
add_subdirectory(src/linter)
endif()

if(BLAZE_TEST)
add_subdirectory(src/test)
endif()
Expand All @@ -67,6 +63,10 @@ if(BLAZE_CONFIGURATION)
add_subdirectory(src/configuration)
endif()

if(BLAZE_ALTERSCHEMA)
add_subdirectory(src/alterschema)
endif()

if(BLAZE_CONTRIB)
add_subdirectory(contrib)
endif()
Expand Down Expand Up @@ -106,10 +106,6 @@ if(BLAZE_TESTS)
add_subdirectory(test/output)
endif()

if(BLAZE_LINTER)
add_subdirectory(test/linter)
endif()

if(BLAZE_TEST)
add_subdirectory(test/test)
endif()
Expand All @@ -118,6 +114,10 @@ if(BLAZE_TESTS)
add_subdirectory(test/configuration)
endif()

if(BLAZE_ALTERSCHEMA)
add_subdirectory(test/alterschema)
endif()

if(PROJECT_IS_TOP_LEVEL)
# Otherwise we need the child project to link
# against the sanitizers too.
Expand Down
2 changes: 1 addition & 1 deletion DEPENDENCIES
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
vendorpull https://github.com/sourcemeta/vendorpull 1dcbac42809cf87cb5b045106b863e17ad84ba02
core https://github.com/sourcemeta/core 94b0c4860231adfb18bb8d16951089f95bc3cc4c
core https://github.com/sourcemeta/core e97b758619b7d483c3940da88bc067705c5e649d
jsonschema-test-suite https://github.com/json-schema-org/JSON-Schema-Test-Suite 06481b143722c8c06671bd40dcde99b422ffd531
8 changes: 6 additions & 2 deletions benchmark/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@ if(BLAZE_COMPILER AND BLAZE_EVALUATOR AND BLAZE_OUTPUT)
micro/2020_12.cc)
endif()

if(BLAZE_ALTERSCHEMA)
list(APPEND BENCHMARK_SOURCES alterschema.cc)
endif()

if(BENCHMARK_SOURCES)
sourcemeta_googlebenchmark(NAMESPACE sourcemeta PROJECT blaze
FOLDER "Blaze" SOURCES ${BENCHMARK_SOURCES})
Expand Down Expand Up @@ -37,9 +41,9 @@ if(BENCHMARK_SOURCES)
target_link_libraries(sourcemeta_blaze_benchmark
PRIVATE sourcemeta::blaze::output)
endif()
if(BLAZE_LINTER)
if(BLAZE_ALTERSCHEMA)
target_link_libraries(sourcemeta_blaze_benchmark
PRIVATE sourcemeta::blaze::linter)
PRIVATE sourcemeta::blaze::alterschema)
endif()

add_custom_target(benchmark_all
Expand Down
116 changes: 116 additions & 0 deletions benchmark/alterschema.cc
Original file line number Diff line number Diff line change
@@ -0,0 +1,116 @@
#include <benchmark/benchmark.h>

#include <cassert> // assert
#include <cstddef> // std::size_t
#include <filesystem> // std::filesystem

#include <sourcemeta/blaze/alterschema.h>
#include <sourcemeta/blaze/compiler.h>
#include <sourcemeta/core/json.h>
#include <sourcemeta/core/jsonschema.h>

static void
Alterschema_Check_Readibility_ISO_Language_Set_3(benchmark::State &state) {
const auto schema{sourcemeta::core::read_json(
std::filesystem::path{CURRENT_DIRECTORY} / "files" /
"2020_12_iso_language_2023_set_3.json")};

sourcemeta::core::SchemaTransformer bundle;
sourcemeta::blaze::add(bundle, sourcemeta::blaze::AlterSchemaMode::Linter);

for (auto _ : state) {
auto result = bundle.check(schema, sourcemeta::core::schema_walker,
sourcemeta::core::schema_resolver,
[](const auto &, const auto &, const auto &,
const auto &, const auto &) {});
assert(result.first);
assert(result.second == 100);
benchmark::DoNotOptimize(result);
}
}

static void Alterschema_Check_Readibility_OMC(benchmark::State &state) {
const auto schema{
sourcemeta::core::read_json(std::filesystem::path{CURRENT_DIRECTORY} /
"files" / "2019_09_omc_json_v2.json")};

sourcemeta::core::SchemaTransformer bundle;
sourcemeta::blaze::add(bundle, sourcemeta::blaze::AlterSchemaMode::Linter);

for (auto _ : state) {
auto result = bundle.check(schema, sourcemeta::core::schema_walker,
sourcemeta::core::schema_resolver,
[](const auto &, const auto &, const auto &,
const auto &, const auto &) {});
assert(!result.first);
benchmark::DoNotOptimize(result);
}
}

static void Alterschema_Check_Readibility_KrakenD(benchmark::State &state) {
const auto schema{
sourcemeta::core::read_json(std::filesystem::path{CURRENT_DIRECTORY} /
"files" / "2019_09_krakend.json")};

sourcemeta::core::SchemaTransformer bundle;
sourcemeta::blaze::add(bundle, sourcemeta::blaze::AlterSchemaMode::Linter);

for (auto _ : state) {
auto result{bundle.check(schema, sourcemeta::core::schema_walker,
sourcemeta::core::schema_resolver,
[](const auto &, const auto &, const auto &,
const auto &, const auto &) {})};
benchmark::DoNotOptimize(result);
}
}

static void Alterschema_Apply_Readibility_KrakenD(benchmark::State &state) {
sourcemeta::core::SchemaTransformer bundle;
sourcemeta::blaze::add(bundle, sourcemeta::blaze::AlterSchemaMode::Linter);

const auto schema{
sourcemeta::core::read_json(std::filesystem::path{CURRENT_DIRECTORY} /
"files" / "2019_09_krakend.json")};

for (auto _ : state) {
state.PauseTiming();
auto copy = schema;
state.ResumeTiming();
auto result = bundle.apply(copy, sourcemeta::core::schema_walker,
sourcemeta::core::schema_resolver,
[](const auto &, const auto &, const auto &,
const auto &, const auto &) {});
assert(!result.first);
benchmark::DoNotOptimize(result);
}
}

static void Alterschema_Check_Invalid_External_Refs(benchmark::State &state) {
const auto schema{sourcemeta::core::read_json(
std::filesystem::path{CURRENT_DIRECTORY} / "files" /
"2020_12_many_invalid_external_refs.json")};

sourcemeta::core::SchemaTransformer bundle;
sourcemeta::blaze::add(bundle, sourcemeta::blaze::AlterSchemaMode::Linter);

for (auto _ : state) {
std::size_t trace_count{0};
auto result = bundle.check(
schema, sourcemeta::core::schema_walker,
sourcemeta::core::schema_resolver,
[&trace_count](const auto &, [[maybe_unused]] const auto &name,
const auto &, const auto &, const auto &) {
assert(name == "invalid_external_ref");
trace_count++;
});
assert(!result.first);
assert(trace_count == 1024);
benchmark::DoNotOptimize(result);
}
}

BENCHMARK(Alterschema_Check_Readibility_ISO_Language_Set_3);
BENCHMARK(Alterschema_Check_Readibility_OMC);
BENCHMARK(Alterschema_Check_Readibility_KrakenD);
BENCHMARK(Alterschema_Apply_Readibility_KrakenD);
BENCHMARK(Alterschema_Check_Invalid_External_Refs);
Loading
Loading