Skip to content

Commit

Permalink
Generalise relativize() as reference_visit() (#1504)
Browse files Browse the repository at this point in the history
Signed-off-by: Juan Cruz Viotti <jv@jviotti.com>
  • Loading branch information
jviotti authored Jan 29, 2025
1 parent 1257bcd commit 8cf5a49
Show file tree
Hide file tree
Showing 6 changed files with 191 additions and 97 deletions.
2 changes: 1 addition & 1 deletion src/core/jsonschema/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ sourcemeta_library(NAMESPACE sourcemeta PROJECT core NAME jsonschema
keywords.h transform.h
SOURCES jsonschema.cc default_walker.cc frame.cc
resolver.cc walker.cc bundle.cc
unevaluated.cc relativize.cc unidentify.cc
unevaluated.cc unidentify.cc
transform_rule.cc transformer.cc
"${CMAKE_CURRENT_BINARY_DIR}/official_resolver.cc")

Expand Down
96 changes: 76 additions & 20 deletions src/core/jsonschema/include/sourcemeta/core/jsonschema.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,10 @@
#include <sourcemeta/core/jsonschema_unevaluated.h>
#include <sourcemeta/core/jsonschema_walker.h>

#include <map> // std::map
#include <optional> // std::optional
#include <string> // std::string
#include <functional> // std::function
#include <map> // std::map
#include <optional> // std::optional
#include <string> // std::string

/// @defgroup jsonschema JSON Schema
/// @brief A set of JSON Schema utilities across draft versions.
Expand Down Expand Up @@ -323,8 +324,8 @@ auto schema_format_compare(const JSON::String &left, const JSON::String &right)

/// @ingroup jsonschema
///
/// Try to turn every possible absolute reference in a schema into a relative
/// one. For example:
/// Remove every identifer from a schema, rephrasing references (if any) as
/// needed. For example:
///
/// ```cpp
/// #include <sourcemeta/core/json.h>
Expand All @@ -335,32 +336,42 @@ auto schema_format_compare(const JSON::String &left, const JSON::String &right)
/// sourcemeta::core::parse_json(R"JSON({
/// "$id": "https://www.example.com/schema",
/// "$schema": "https://json-schema.org/draft/2020-12/schema",
/// "$ref": "https://www.example.com/another",
/// "$ref": "another",
/// })JSON");
///
/// sourcemeta::core::relativize(schema,
/// sourcemeta::core::unidentify(schema,
/// sourcemeta::core::schema_official_walker,
/// sourcemeta::core::official_resolver);
///
/// const sourcemeta::core::JSON expected =
/// sourcemeta::core::parse_json(R"JSON({
/// "$id": "https://www.example.com/schema",
/// "$schema": "https://json-schema.org/draft/2020-12/schema",
/// "$ref": "another",
/// "$ref": "https://www.example.com/another",
/// })JSON");
///
/// assert(schema == expected);
/// ```
SOURCEMETA_CORE_JSONSCHEMA_EXPORT
auto relativize(
auto unidentify(
JSON &schema, const SchemaWalker &walker, const SchemaResolver &resolver,
const std::optional<std::string> &default_dialect = std::nullopt,
const std::optional<std::string> &default_id = std::nullopt) -> void;
const std::optional<std::string> &default_dialect = std::nullopt) -> void;

/// @ingroup jsonschema
///
/// Remove every identifer from a schema, rephrasing references (if any) as
/// needed. For example:
/// Visit every reference in a schema. The arguments are as follows:
///
/// - The current subschema
/// - The base URI of the current subschema
/// - The reference vocabulary
/// - The reference keyword name
/// - The reference reference destination
using SchemaVisitorReference = std::function<void(
JSON &, const URI &, const JSON::String &, const JSON::String &, URI &)>;

/// @ingroup jsonschema
///
/// A reference visitor to try to turn every possible absolute reference in a
/// schema into a relative one. For example:
///
/// ```cpp
/// #include <sourcemeta/core/json.h>
Expand All @@ -371,25 +382,70 @@ auto relativize(
/// sourcemeta::core::parse_json(R"JSON({
/// "$id": "https://www.example.com/schema",
/// "$schema": "https://json-schema.org/draft/2020-12/schema",
/// "$ref": "another",
/// "$ref": "https://www.example.com/another",
/// })JSON");
///
/// sourcemeta::core::unidentify(schema,
/// sourcemeta::core::reference_visit(schema,
/// sourcemeta::core::schema_official_walker,
/// sourcemeta::core::official_resolver);
/// sourcemeta::core::official_resolver,
/// sourcemeta::core::reference_visitor_relativize);
///
/// const sourcemeta::core::JSON expected =
/// sourcemeta::core::parse_json(R"JSON({
/// "$id": "https://www.example.com/schema",
/// "$schema": "https://json-schema.org/draft/2020-12/schema",
/// "$ref": "https://www.example.com/another",
/// "$ref": "another",
/// })JSON");
///
/// assert(schema == expected);
/// ```
SOURCEMETA_CORE_JSONSCHEMA_EXPORT
auto unidentify(
auto reference_visitor_relativize(JSON &subschema, const URI &base,
const JSON::String &vocabulary,
const JSON::String &keyword, URI &value)
-> void;

/// @ingroup jsonschema
///
/// A utility function to loop over every reference in a schema, allowing
/// modifications to their subschemas if desired. Note that the consumer is
/// responsible for not making the schema invalid. For example:
///
/// ```cpp
/// #include <sourcemeta/core/json.h>
/// #include <sourcemeta/core/jsonschema.h>
///
/// sourcemeta::core::JSON schema =
/// sourcemeta::core::parse_json(R"JSON({
/// "$id": "https://www.example.com/schema",
/// "$schema": "https://json-schema.org/draft/2020-12/schema",
/// "$ref": "https://www.example.com/another",
/// })JSON");
///
/// static auto visitor(JSON &subschema,
/// const URI &base,
/// const JSON::String &vocabulary,
/// const JSON::String &keyword,
/// URI &value) -> void {
/// sourcemeta::core::prettify(subschema, std::cerr);
/// std::cerr << "\n";
/// std::cerr << base.recompose() << "\n";
/// std::cerr << vocabulary << "\n";
/// std::cerr << keyword << "\n";
/// std::cerr << value.recompose() << "\n";
/// }
///
/// sourcemeta::core::reference_visit(schema,
/// sourcemeta::core::schema_official_walker,
/// sourcemeta::core::official_resolver,
/// visitor);
/// ```
SOURCEMETA_CORE_JSONSCHEMA_EXPORT
auto reference_visit(
JSON &schema, const SchemaWalker &walker, const SchemaResolver &resolver,
const std::optional<std::string> &default_dialect = std::nullopt) -> void;
const SchemaVisitorReference &callback,
const std::optional<std::string> &default_dialect = std::nullopt,
const std::optional<std::string> &default_id = std::nullopt) -> void;

} // namespace sourcemeta::core

Expand Down
65 changes: 65 additions & 0 deletions src/core/jsonschema/jsonschema.cc
Original file line number Diff line number Diff line change
Expand Up @@ -547,3 +547,68 @@ auto sourcemeta::core::schema_format_compare(
return left < right;
}
}

auto sourcemeta::core::reference_visit(
sourcemeta::core::JSON &schema,
const sourcemeta::core::SchemaWalker &walker,
const sourcemeta::core::SchemaResolver &resolver,
const sourcemeta::core::SchemaVisitorReference &callback,
const std::optional<std::string> &default_dialect,
const std::optional<std::string> &default_id) -> void {
sourcemeta::core::SchemaFrame frame;
frame.analyse(schema, walker, resolver, default_dialect, default_id);
for (const auto &entry : frame.locations()) {
if (entry.second.type !=
sourcemeta::core::SchemaFrame::LocationType::Resource &&
entry.second.type !=
sourcemeta::core::SchemaFrame::LocationType::Subschema) {
continue;
}

auto &subschema{sourcemeta::core::get(schema, entry.second.pointer)};
assert(sourcemeta::core::is_schema(subschema));
if (!subschema.is_object()) {
continue;
}

const sourcemeta::core::URI base{entry.second.base};
// Assume the base is canonicalized already
assert(
sourcemeta::core::URI{entry.second.base}.canonicalize().recompose() ==
base.recompose());
for (const auto &property : subschema.as_object()) {
const auto walker_result{
walker(property.first, frame.vocabularies(entry.second, resolver))};
if (walker_result.type !=
sourcemeta::core::SchemaKeywordType::Reference ||
!property.second.is_string()) {
continue;
}

assert(property.second.is_string());
assert(walker_result.vocabulary.has_value());
sourcemeta::core::URI reference{property.second.to_string()};
callback(subschema, base, walker_result.vocabulary.value(),
property.first, reference);
}
}
}

auto sourcemeta::core::reference_visitor_relativize(
sourcemeta::core::JSON &subschema, const sourcemeta::core::URI &base,
const sourcemeta::core::JSON::String &vocabulary,
const sourcemeta::core::JSON::String &keyword, URI &reference) -> void {
// In 2019-09, `$recursiveRef` can only be `#`, so there
// is nothing else we can possibly do
if (vocabulary == "https://json-schema.org/draft/2019-09/vocab/core" &&
keyword == "$recursiveRef") {
return;
}

reference.relative_to(base);
reference.canonicalize();

if (reference.is_relative()) {
subschema.assign(keyword, sourcemeta::core::JSON{reference.recompose()});
}
}
49 changes: 0 additions & 49 deletions src/core/jsonschema/relativize.cc

This file was deleted.

7 changes: 4 additions & 3 deletions src/core/jsonschema/resolver.cc
Original file line number Diff line number Diff line change
Expand Up @@ -150,9 +150,10 @@ auto SchemaFlatFileResolver::operator()(std::string_view identifier) const
*this, result->second.default_dialect);
// Because we allow re-identification, we can get into issues unless we
// always try to relativize references
sourcemeta::core::relativize(schema, schema_official_walker, *this,
result->second.default_dialect,
result->second.original_identifier);
sourcemeta::core::reference_visit(
schema, schema_official_walker, *this,
sourcemeta::core::reference_visitor_relativize,
result->second.default_dialect, result->second.original_identifier);
sourcemeta::core::reidentify(schema, result->first, *this,
result->second.default_dialect);

Expand Down
Loading

5 comments on commit 8cf5a49

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Benchmark (linux/llvm)

Benchmark suite Current: 8cf5a49 Previous: 1257bcd Ratio
Regex_Lower_S_Or_Upper_S_Asterisk 2.2270752955242745 ns/iter 2.205439895388263 ns/iter 1.01
Regex_Caret_Lower_S_Or_Upper_S_Asterisk_Dollar 2.207675952314714 ns/iter 2.2126817072631573 ns/iter 1.00
Regex_Period_Asterisk 2.202200757276197 ns/iter 2.2034129072151956 ns/iter 1.00
Regex_Group_Period_Asterisk_Group 2.2110025339181525 ns/iter 2.213023754340643 ns/iter 1.00
Regex_Period_Plus 2.8006313272732815 ns/iter 2.4860243981552057 ns/iter 1.13
Regex_Period 2.7994861256969363 ns/iter 2.487332853235051 ns/iter 1.13
Regex_Caret_Period_Plus_Dollar 2.7999675253821747 ns/iter 2.4864510430072015 ns/iter 1.13
Regex_Caret_Group_Period_Plus_Group_Dollar 2.799551506131991 ns/iter 2.4887675853391213 ns/iter 1.12
Regex_Caret_Period_Asterisk_Dollar 3.418952988534301 ns/iter 2.4861564142463153 ns/iter 1.38
Regex_Caret_Group_Period_Asterisk_Group_Dollar 3.4207344150709846 ns/iter 2.4859757167804397 ns/iter 1.38
Regex_Caret_X_Hyphen 13.064675190195798 ns/iter 12.545757840382844 ns/iter 1.04
Regex_Period_Md_Dollar 81.73306018112471 ns/iter 81.93226215139974 ns/iter 1.00
Regex_Caret_Slash_Period_Asterisk 6.838112570380814 ns/iter 5.5975533577868966 ns/iter 1.22
Regex_Caret_Period_Range_Dollar 4.046297873256092 ns/iter 3.109692667794566 ns/iter 1.30
Regex_Nested_Backtrack 499.36500454443814 ns/iter 498.7616609403319 ns/iter 1.00
JSON_Array_Of_Objects_Unique 408.4433899067244 ns/iter 403.8794275729227 ns/iter 1.01
JSON_Parse_1 30296.929983060272 ns/iter 30355.308840811966 ns/iter 1.00
JSON_Fast_Hash_Helm_Chart_Lock 59.357573665400025 ns/iter 59.397387661783384 ns/iter 1.00
JSON_Equality_Helm_Chart_Lock 157.0616992042028 ns/iter 152.3325775459292 ns/iter 1.03
JSON_String_Equal/10 6.222476464624364 ns/iter 6.278630441306394 ns/iter 0.99
JSON_String_Equal/100 6.850214845462466 ns/iter 6.844555140583583 ns/iter 1.00
JSON_String_Equal_Small_By_Perfect_Hash/10 0.9352128189554774 ns/iter 0.9349485886262672 ns/iter 1.00
JSON_String_Equal_Small_By_Runtime_Perfect_Hash/10 14.604966453864959 ns/iter 14.596761932766306 ns/iter 1.00
JSON_String_Fast_Hash/10 2.48967114275639 ns/iter 2.4905365115606246 ns/iter 1.00
JSON_String_Fast_Hash/100 2.489231626350758 ns/iter 2.485866395952339 ns/iter 1.00
JSON_String_Key_Hash/10 2.656484066800175 ns/iter 2.689432798418405 ns/iter 0.99
JSON_String_Key_Hash/100 1.890100562728237 ns/iter 1.8681679855168551 ns/iter 1.01
JSON_Object_Defines_Miss_Same_Length 3.7361104835252883 ns/iter 3.7388454434520777 ns/iter 1.00
JSON_Object_Defines_Miss_Too_Small 3.7799533215937986 ns/iter 3.7326965893851694 ns/iter 1.01
JSON_Object_Defines_Miss_Too_Large 3.7376513129595206 ns/iter 3.7505857611722533 ns/iter 1.00
Pointer_Object_Traverse 44.38814616809202 ns/iter 44.38106578275717 ns/iter 1.00
Pointer_Object_Try_Traverse 52.357129476188504 ns/iter 52.27888260706735 ns/iter 1.00
Pointer_Push_Back_Pointer_To_Weak_Pointer 308.51627054204283 ns/iter 305.27287609245764 ns/iter 1.01

This comment was automatically generated by workflow using github-action-benchmark.

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Benchmark (macos/llvm)

Benchmark suite Current: 8cf5a49 Previous: 1257bcd Ratio
Regex_Lower_S_Or_Upper_S_Asterisk 2.2458258585886375 ns/iter 1.6242845443964553 ns/iter 1.38
Regex_Caret_Lower_S_Or_Upper_S_Asterisk_Dollar 1.9312792320088579 ns/iter 1.62502555568287 ns/iter 1.19
Regex_Period_Asterisk 1.8543390971448808 ns/iter 1.622499673363136 ns/iter 1.14
Regex_Group_Period_Asterisk_Group 1.935738423508453 ns/iter 1.6238151160451513 ns/iter 1.19
Regex_Period_Plus 2.2141495336060437 ns/iter 1.9451339990160716 ns/iter 1.14
Regex_Period 2.644948429650571 ns/iter 1.9534369697853329 ns/iter 1.35
Regex_Caret_Period_Plus_Dollar 2.570080828177242 ns/iter 1.9633298920162394 ns/iter 1.31
Regex_Caret_Group_Period_Plus_Group_Dollar 2.5520923010991994 ns/iter 1.9477453562108746 ns/iter 1.31
Regex_Caret_Period_Asterisk_Dollar 2.1989583374446973 ns/iter 1.622410727080435 ns/iter 1.36
Regex_Caret_Group_Period_Asterisk_Group_Dollar 2.382166543386614 ns/iter 1.6324873128085118 ns/iter 1.46
Regex_Caret_X_Hyphen 8.966162205468052 ns/iter 6.811802070955476 ns/iter 1.32
Regex_Period_Md_Dollar 93.469451320087 ns/iter 69.70843315133743 ns/iter 1.34
Regex_Caret_Slash_Period_Asterisk 7.462991725297044 ns/iter 5.20808304942807 ns/iter 1.43
Regex_Caret_Period_Range_Dollar 3.1015821852281773 ns/iter 2.2738404350183 ns/iter 1.36
Regex_Nested_Backtrack 978.3882679102969 ns/iter 749.175204166856 ns/iter 1.31
JSON_Array_Of_Objects_Unique 444.1164198936398 ns/iter 339.19625607073755 ns/iter 1.31
JSON_Parse_1 30990.432252770446 ns/iter 22336.549090328874 ns/iter 1.39
JSON_Fast_Hash_Helm_Chart_Lock 69.16707412128278 ns/iter 50.39685420000524 ns/iter 1.37
JSON_Equality_Helm_Chart_Lock 155.37048034859276 ns/iter 123.07386589409097 ns/iter 1.26
JSON_String_Equal/10 10.019955892640828 ns/iter 7.7912150726090665 ns/iter 1.29
JSON_String_Equal/100 8.255261094801297 ns/iter 6.181523996244418 ns/iter 1.34
JSON_String_Equal_Small_By_Perfect_Hash/10 0.4339872702313934 ns/iter 0.3258073992922958 ns/iter 1.33
JSON_String_Equal_Small_By_Runtime_Perfect_Hash/10 4.06682891629415 ns/iter 3.0037047353187116 ns/iter 1.35
JSON_String_Fast_Hash/10 2.1543049444411198 ns/iter 1.6223881575700625 ns/iter 1.33
JSON_String_Fast_Hash/100 2.4844176838821723 ns/iter 1.9462895786067127 ns/iter 1.28
JSON_String_Key_Hash/10 1.6432286027783927 ns/iter 1.2966909302510439 ns/iter 1.27
JSON_String_Key_Hash/100 1.6638998993855616 ns/iter 1.2970551377198365 ns/iter 1.28
JSON_Object_Defines_Miss_Same_Length 3.335863760964066 ns/iter 2.271712336590028 ns/iter 1.47
JSON_Object_Defines_Miss_Too_Small 3.025926662150068 ns/iter 2.272053646905853 ns/iter 1.33
JSON_Object_Defines_Miss_Too_Large 3.0978096616726676 ns/iter 2.2769966015672507 ns/iter 1.36
Pointer_Object_Traverse 25.33617080616605 ns/iter 17.537894980485266 ns/iter 1.44
Pointer_Object_Try_Traverse 29.100240898907977 ns/iter 22.51325369929288 ns/iter 1.29
Pointer_Push_Back_Pointer_To_Weak_Pointer 217.5574601891273 ns/iter 179.1921423341727 ns/iter 1.21

This comment was automatically generated by workflow using github-action-benchmark.

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Benchmark (windows/msvc)

Benchmark suite Current: 8cf5a49 Previous: 1257bcd Ratio
Regex_Lower_S_Or_Upper_S_Asterisk 7.24306808035686 ns/iter 6.871592633928003 ns/iter 1.05
Regex_Caret_Lower_S_Or_Upper_S_Asterisk_Dollar 6.903044642856214 ns/iter 6.895277901785489 ns/iter 1.00
Regex_Period_Asterisk 7.315520056630072 ns/iter 7.614353537436987 ns/iter 0.96
Regex_Group_Period_Asterisk_Group 7.019067825807428 ns/iter 6.916473214284886 ns/iter 1.01
Regex_Period_Plus 7.697251304924719 ns/iter 7.235312500001154 ns/iter 1.06
Regex_Period 7.697978794641053 ns/iter 7.431838169643815 ns/iter 1.04
Regex_Caret_Period_Plus_Dollar 7.465769163100739 ns/iter 7.424514285714524 ns/iter 1.01
Regex_Caret_Group_Period_Plus_Group_Dollar 7.185964285714164 ns/iter 7.2622868303590895 ns/iter 0.99
Regex_Caret_Period_Asterisk_Dollar 7.172145503696643 ns/iter 7.008048183000505 ns/iter 1.02
Regex_Caret_Group_Period_Asterisk_Group_Dollar 6.890382812499191 ns/iter 6.838024553569459 ns/iter 1.01
Regex_Caret_X_Hyphen 11.797003571428734 ns/iter 14.253828284581564 ns/iter 0.83
Regex_Period_Md_Dollar 150.34085489550088 ns/iter 150.70595982145107 ns/iter 1.00
Regex_Caret_Slash_Period_Asterisk 10.842842187500423 ns/iter 10.442409375002626 ns/iter 1.04
Regex_Caret_Period_Range_Dollar 7.719560267859091 ns/iter 7.601148437499055 ns/iter 1.02
Regex_Nested_Backtrack 649.7722321427091 ns/iter 613.0490178571384 ns/iter 1.06
JSON_Array_Of_Objects_Unique 490.42293557595747 ns/iter 487.9731047266473 ns/iter 1.01
JSON_Parse_1 80885.9381277624 ns/iter 80341.9196428631 ns/iter 1.01
JSON_Fast_Hash_Helm_Chart_Lock 62.425937500003265 ns/iter 63.768937500015 ns/iter 0.98
JSON_Equality_Helm_Chart_Lock 185.69874681018902 ns/iter 186.75857723832897 ns/iter 0.99
JSON_String_Equal/10 9.060500852411069 ns/iter 8.97046986607007 ns/iter 1.01
JSON_String_Equal/100 10.03044999999858 ns/iter 9.896705312960087 ns/iter 1.01
JSON_String_Equal_Small_By_Perfect_Hash/10 2.16822500000049 ns/iter 2.1649006250001435 ns/iter 1.00
JSON_String_Equal_Small_By_Runtime_Perfect_Hash/10 15.290882279387597 ns/iter 14.583394768417666 ns/iter 1.05
JSON_String_Fast_Hash/10 4.030949471484057 ns/iter 4.029120185765581 ns/iter 1.00
JSON_String_Fast_Hash/100 4.024913757186968 ns/iter 4.02546451611665 ns/iter 1.00
JSON_String_Key_Hash/10 8.000596839284164 ns/iter 7.736486607142926 ns/iter 1.03
JSON_String_Key_Hash/100 4.0305541294648 ns/iter 4.018915736607097 ns/iter 1.00
JSON_Object_Defines_Miss_Same_Length 3.724511243349552 ns/iter 3.712352671942207 ns/iter 1.00
JSON_Object_Defines_Miss_Too_Small 4.9622619999991 ns/iter 4.960622077000618 ns/iter 1.00
JSON_Object_Defines_Miss_Too_Large 3.403632405395875 ns/iter 3.4072256303244104 ns/iter 1.00
Pointer_Object_Traverse 50.38366000001133 ns/iter 49.056687500004564 ns/iter 1.03
Pointer_Object_Try_Traverse 67.52850000000063 ns/iter 67.76957589284142 ns/iter 1.00
Pointer_Push_Back_Pointer_To_Weak_Pointer 178.62923294392743 ns/iter 170.63824803384645 ns/iter 1.05

This comment was automatically generated by workflow using github-action-benchmark.

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Benchmark (linux/gcc)

Benchmark suite Current: 8cf5a49 Previous: 1257bcd Ratio
Pointer_Object_Traverse 46.71411734798 ns/iter 46.72699325767282 ns/iter 1.00
Pointer_Object_Try_Traverse 26.14048997993231 ns/iter 26.188059629886595 ns/iter 1.00
Pointer_Push_Back_Pointer_To_Weak_Pointer 145.31897559497136 ns/iter 145.2481230307094 ns/iter 1.00
JSON_Array_Of_Objects_Unique 413.42395277071915 ns/iter 415.3623936739927 ns/iter 1.00
JSON_Parse_1 33385.22039848418 ns/iter 33661.15866928358 ns/iter 0.99
JSON_Fast_Hash_Helm_Chart_Lock 69.07388741767379 ns/iter 68.83588568649263 ns/iter 1.00
JSON_Equality_Helm_Chart_Lock 149.26452424409166 ns/iter 149.54224050901766 ns/iter 1.00
JSON_String_Equal/10 6.3403048631384245 ns/iter 6.345388239459724 ns/iter 1.00
JSON_String_Equal/100 6.963749028481358 ns/iter 7.01363113078847 ns/iter 0.99
JSON_String_Equal_Small_By_Perfect_Hash/10 0.9354327199278691 ns/iter 0.9347266704606404 ns/iter 1.00
JSON_String_Equal_Small_By_Runtime_Perfect_Hash/10 14.289882425946328 ns/iter 14.292050205515787 ns/iter 1.00
JSON_String_Fast_Hash/10 0.9342627895567384 ns/iter 0.9350701900004398 ns/iter 1.00
JSON_String_Fast_Hash/100 0.932895891227248 ns/iter 0.937087401162159 ns/iter 1.00
JSON_String_Key_Hash/10 1.6716531927153484 ns/iter 1.671596716626417 ns/iter 1.00
JSON_String_Key_Hash/100 1.9834161416244755 ns/iter 2.0421013904697034 ns/iter 0.97
JSON_Object_Defines_Miss_Same_Length 2.4890638744520786 ns/iter 2.493658442781414 ns/iter 1.00
JSON_Object_Defines_Miss_Too_Small 2.48705927605561 ns/iter 2.490102170819413 ns/iter 1.00
JSON_Object_Defines_Miss_Too_Large 3.109234691331528 ns/iter 3.108175935748401 ns/iter 1.00
Regex_Lower_S_Or_Upper_S_Asterisk 3.4198182886389636 ns/iter 3.4182006829022353 ns/iter 1.00
Regex_Caret_Lower_S_Or_Upper_S_Asterisk_Dollar 3.4187201887066236 ns/iter 3.419306177994497 ns/iter 1.00
Regex_Period_Asterisk 3.420889915103344 ns/iter 3.4243828349055567 ns/iter 1.00
Regex_Group_Period_Asterisk_Group 3.4224694944648495 ns/iter 3.435013680213748 ns/iter 1.00
Regex_Period_Plus 3.732624775676041 ns/iter 3.7349874050308993 ns/iter 1.00
Regex_Period 3.7303412661503 ns/iter 3.7315567909304734 ns/iter 1.00
Regex_Caret_Period_Plus_Dollar 3.7357351956493456 ns/iter 3.737034539386885 ns/iter 1.00
Regex_Caret_Group_Period_Plus_Group_Dollar 3.7310337523264856 ns/iter 3.742940083824722 ns/iter 1.00
Regex_Caret_Period_Asterisk_Dollar 4.1000549445494885 ns/iter 3.4292197649776157 ns/iter 1.20
Regex_Caret_Group_Period_Asterisk_Group_Dollar 3.4232389819670206 ns/iter 3.423995798986543 ns/iter 1.00
Regex_Caret_X_Hyphen 12.438545401603536 ns/iter 13.119482776908558 ns/iter 0.95
Regex_Period_Md_Dollar 89.67561540643806 ns/iter 89.7816024050595 ns/iter 1.00
Regex_Caret_Slash_Period_Asterisk 7.000837346067002 ns/iter 7.148802349926032 ns/iter 0.98
Regex_Caret_Period_Range_Dollar 3.419181450041491 ns/iter 4.665792559533156 ns/iter 0.73
Regex_Nested_Backtrack 817.1496088193188 ns/iter 817.8560000000089 ns/iter 1.00

This comment was automatically generated by workflow using github-action-benchmark.

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Benchmark (macos/gcc)

Benchmark suite Current: 8cf5a49 Previous: 1257bcd Ratio
Regex_Lower_S_Or_Upper_S_Asterisk 2.1474114065616297 ns/iter 1.9531142180088146 ns/iter 1.10
Regex_Caret_Lower_S_Or_Upper_S_Asterisk_Dollar 2.097186850711712 ns/iter 1.9498255446131942 ns/iter 1.08
Regex_Period_Asterisk 2.104534677862823 ns/iter 1.9779014130368056 ns/iter 1.06
Regex_Group_Period_Asterisk_Group 2.1477959861472034 ns/iter 1.9509459980409456 ns/iter 1.10
Regex_Period_Plus 2.106017485637286 ns/iter 1.9621694685633304 ns/iter 1.07
Regex_Period 2.1471174639873305 ns/iter 1.949194914185844 ns/iter 1.10
Regex_Caret_Period_Plus_Dollar 2.477149789943814 ns/iter 1.9527610996306506 ns/iter 1.27
Regex_Caret_Group_Period_Plus_Group_Dollar 2.153035969708371 ns/iter 1.9511618218346114 ns/iter 1.10
Regex_Caret_Period_Asterisk_Dollar 2.1077532788910704 ns/iter 1.9427383078363005 ns/iter 1.08
Regex_Caret_Group_Period_Asterisk_Group_Dollar 2.449274790967231 ns/iter 2.278289086454607 ns/iter 1.08
Regex_Caret_X_Hyphen 7.358027784551672 ns/iter 6.152429629480925 ns/iter 1.20
Regex_Period_Md_Dollar 79.35266264829255 ns/iter 73.45754822765414 ns/iter 1.08
Regex_Caret_Slash_Period_Asterisk 5.125080256705062 ns/iter 4.3973732440260225 ns/iter 1.17
Regex_Caret_Period_Range_Dollar 2.094043830778999 ns/iter 1.9452588904485049 ns/iter 1.08
Regex_Nested_Backtrack 879.9034618945302 ns/iter 823.475558385263 ns/iter 1.07
JSON_Array_Of_Objects_Unique 234.61476147545105 ns/iter 197.1921061149052 ns/iter 1.19
JSON_Parse_1 25499.527461027996 ns/iter 22784.70619556691 ns/iter 1.12
JSON_Fast_Hash_Helm_Chart_Lock 26.62064859441013 ns/iter 23.579894551111536 ns/iter 1.13
JSON_Equality_Helm_Chart_Lock 126.48953626974541 ns/iter 114.10370617442618 ns/iter 1.11
JSON_String_Equal/10 5.776251818090912 ns/iter 5.386388274571394 ns/iter 1.07
JSON_String_Equal/100 5.54141518039224 ns/iter 5.056697923911345 ns/iter 1.10
JSON_String_Equal_Small_By_Perfect_Hash/10 0.801659643317213 ns/iter 0.744421713776442 ns/iter 1.08
JSON_String_Equal_Small_By_Runtime_Perfect_Hash/10 3.7319907230811404 ns/iter 3.4459626026403023 ns/iter 1.08
JSON_String_Fast_Hash/10 2.0311515513602623 ns/iter 1.8910378419897973 ns/iter 1.07
JSON_String_Fast_Hash/100 2.0411049611975653 ns/iter 1.8918060223814475 ns/iter 1.08
JSON_String_Key_Hash/10 1.5527776129163937 ns/iter 1.4571920086559111 ns/iter 1.07
JSON_String_Key_Hash/100 2.0730944322752256 ns/iter 1.919586164786371 ns/iter 1.08
JSON_Object_Defines_Miss_Same_Length 1.9022250347431315 ns/iter 1.72887396665273 ns/iter 1.10
JSON_Object_Defines_Miss_Too_Small 2.04070451461554 ns/iter 1.9600240064695464 ns/iter 1.04
JSON_Object_Defines_Miss_Too_Large 2.369642906381747 ns/iter 1.729811086743139 ns/iter 1.37
Pointer_Object_Traverse 69.58990923492337 ns/iter 54.385964188424914 ns/iter 1.28
Pointer_Object_Try_Traverse 38.753988591279374 ns/iter 36.15190856917258 ns/iter 1.07
Pointer_Push_Back_Pointer_To_Weak_Pointer 167.29791605641006 ns/iter 154.00825395065823 ns/iter 1.09

This comment was automatically generated by workflow using github-action-benchmark.

Please sign in to comment.