Skip to content

Commit

Permalink
Implement TransformRule in the JSON Schema module (#1482)
Browse files Browse the repository at this point in the history
Signed-off-by: Juan Cruz Viotti <[email protected]>
  • Loading branch information
jviotti authored Jan 27, 2025
1 parent f285701 commit 0fc100e
Show file tree
Hide file tree
Showing 7 changed files with 405 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/core/jsonschema/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,12 @@ include(./official_resolver.cmake)
noa_library(NAMESPACE sourcemeta PROJECT jsontoolkit NAME jsonschema
FOLDER "JSON Toolkit/JSON Schema"
PRIVATE_HEADERS anchor.h bundle.h resolver.h
walker.h reference.h frame.h error.h unevaluated.h keywords.h
walker.h reference.h frame.h error.h unevaluated.h
keywords.h transform.h
SOURCES jsonschema.cc default_walker.cc frame.cc
anchor.cc resolver.cc walker.cc bundle.cc
unevaluated.cc relativize.cc unidentify.cc
transform_rule.cc
"${CMAKE_CURRENT_BINARY_DIR}/official_resolver.cc")

if(JSONTOOLKIT_INSTALL)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
#include <sourcemeta/jsontoolkit/jsonschema_keywords.h>
#include <sourcemeta/jsontoolkit/jsonschema_reference.h>
#include <sourcemeta/jsontoolkit/jsonschema_resolver.h>
#include <sourcemeta/jsontoolkit/jsonschema_transform.h>
#include <sourcemeta/jsontoolkit/jsonschema_unevaluated.h>
#include <sourcemeta/jsontoolkit/jsonschema_walker.h>

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,111 @@
#ifndef SOURCEMETA_JSONTOOLKIT_JSONSCHEMA_RULE_H_
#define SOURCEMETA_JSONTOOLKIT_JSONSCHEMA_RULE_H_

#ifndef SOURCEMETA_JSONTOOLKIT_JSONSCHEMA_EXPORT
#include <sourcemeta/jsontoolkit/jsonschema_export.h>
#endif

#include <sourcemeta/jsontoolkit/json.h>
#include <sourcemeta/jsontoolkit/jsonpointer.h>
#include <sourcemeta/jsontoolkit/jsonschema_resolver.h>

#include <optional> // std::optional, std::nullopt
#include <set> // std::set
#include <string> // std::string
#include <vector> // std::vector

namespace sourcemeta::jsontoolkit {
/// @ingroup jsonschema
///
/// A class that represents a transformation rule. Clients of this class
/// are expected to subclass and implement their own condition and
/// transformation methods.
///
/// For example, this is a rule that deletes any property called `foo` in every
/// subschema:
///
/// ```cpp
/// #include <sourcemeta/jsontoolkit/jsonschema.h>
///
/// class MyTransformRule final
/// : public sourcemeta::jsontoolkit::TransformRule {
/// public:
/// MyTransformRule() : sourcemeta::jsontoolkit::TransformRule("my_rule", "My
/// rule") {};
///
/// [[nodiscard]] auto condition(const sourcemeta::jsontoolkit::JSON &schema,
/// const std::string &dialect,
/// const std::set<std::string> &vocabularies,
/// const sourcemeta::jsontoolkit::Pointer
/// &pointer) const
/// -> bool override
/// return schema.defines("foo");
/// }
///
/// auto transform(sourcemeta::jsontoolkit::PointerProxy &transformer)
/// const -> void override {
/// transformer.erase("foo");
/// }
/// };
/// ```
class SOURCEMETA_JSONTOOLKIT_JSONSCHEMA_EXPORT TransformRule {
public:
/// Create a transformation rule. Each rule must have a unique name.
TransformRule(std::string &&name, std::string &&message);

// Necessary to wrap rules on smart pointers
virtual ~TransformRule() = default;

// We don't need any of these
TransformRule(const TransformRule &) = delete;
TransformRule(TransformRule &&) = delete;
auto operator=(const TransformRule &) -> TransformRule & = delete;
auto operator=(TransformRule &&) -> TransformRule & = delete;

/// Compare a rule against another rule.
auto operator==(const TransformRule &other) const -> bool;

/// Fetch the name of a rule
[[nodiscard]] auto name() const -> const std::string &;

/// Fetch the message of a rule
[[nodiscard]] auto message() const -> const std::string &;

/// Apply the rule to a schema
auto
apply(JSON &schema, const Pointer &pointer, const SchemaResolver &resolver,
const std::optional<std::string> &default_dialect = std::nullopt) const
-> std::vector<PointerProxy::Operation>;

/// Check if the rule applies to a schema
auto
check(const JSON &schema, const Pointer &pointer,
const SchemaResolver &resolver,
const std::optional<std::string> &default_dialect = std::nullopt) const
-> bool;

private:
/// The rule condition
[[nodiscard]] virtual auto
condition(const JSON &schema, const std::string &dialect,
const std::set<std::string> &vocabularies,
const Pointer &pointer) const -> bool = 0;

/// The rule transformation
virtual auto transform(PointerProxy &transformer) const -> void = 0;

// Exporting symbols that depends on the standard C++ library is considered
// safe.
// https://learn.microsoft.com/en-us/cpp/error-messages/compiler-warnings/compiler-warning-level-2-c4275?view=msvc-170&redirectedfrom=MSDN
#if defined(_MSC_VER)
#pragma warning(disable : 4251)
#endif
const std::string name_;
const std::string message_;
#if defined(_MSC_VER)
#pragma warning(default : 4251)
#endif
};
} // namespace sourcemeta::jsontoolkit

#endif
86 changes: 86 additions & 0 deletions src/core/jsonschema/transform_rule.cc
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
#include <sourcemeta/jsontoolkit/jsonschema.h>

#include <cassert> // assert
#include <sstream> // std::ostringstream
#include <stdexcept> // std::runtime_error
#include <utility> // std::move

namespace {

auto vocabularies_to_set(const std::map<std::string, bool> &vocabularies)
-> std::set<std::string> {
std::set<std::string> result;
for (const auto &pair : vocabularies) {
result.insert(pair.first);
}

return result;
}

} // namespace

namespace sourcemeta::jsontoolkit {

TransformRule::TransformRule(std::string &&name, std::string &&message)
: name_{std::move(name)}, message_{std::move(message)} {}

auto TransformRule::operator==(const TransformRule &other) const -> bool {
return this->name() == other.name();
}

auto TransformRule::name() const -> const std::string & { return this->name_; }

auto TransformRule::message() const -> const std::string & {
return this->message_;
}

auto TransformRule::apply(
JSON &schema, const Pointer &pointer, const SchemaResolver &resolver,
const std::optional<std::string> &default_dialect) const
-> std::vector<PointerProxy::Operation> {
const std::optional<std::string> effective_dialect{
dialect(schema, default_dialect)};
if (!effective_dialect.has_value()) {
throw SchemaError("Could not determine the schema dialect");
}

const auto current_vocabularies{
vocabularies_to_set(vocabularies(schema, resolver, default_dialect))};
if (!this->condition(schema, effective_dialect.value(), current_vocabularies,
pointer)) {
return {};
}

PointerProxy transformer{schema};
this->transform(transformer);
// Otherwise the transformation didn't do anything
assert(!transformer.traces().empty());

// The condition must always be false after applying the
// transformation in order to avoid infinite loops
if (this->condition(schema, effective_dialect.value(), current_vocabularies,
pointer)) {
std::ostringstream error;
error << "Rule condition holds after application: " << this->name();
throw std::runtime_error(error.str());
}

return transformer.traces();
}

auto TransformRule::check(
const JSON &schema, const Pointer &pointer, const SchemaResolver &resolver,
const std::optional<std::string> &default_dialect) const -> bool {
const std::optional<std::string> effective_dialect{
dialect(schema, default_dialect)};
if (!effective_dialect.has_value()) {
throw SchemaError("Could not determine the schema dialect");
}

return this->condition(
schema, effective_dialect.value(),
vocabularies_to_set(vocabularies(schema, resolver, default_dialect)),
pointer);
}

} // namespace sourcemeta::jsontoolkit
2 changes: 2 additions & 0 deletions test/jsonschema/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@ noa_googletest(NAMESPACE sourcemeta PROJECT jsontoolkit NAME jsonschema
jsonschema_bundle_test.cc
jsonschema_unidentify_test.cc
jsonschema_metaschema_test.cc
jsonschema_transform_rules.h
jsonschema_transform_rule_test.cc
jsonschema_dialect_test.cc
jsonschema_dialect_2020_12_test.cc
jsonschema_dialect_2019_09_test.cc
Expand Down
32 changes: 32 additions & 0 deletions test/jsonschema/jsonschema_transform_rule_test.cc
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
#include <gtest/gtest.h>

#include <memory>

#include <sourcemeta/jsontoolkit/json.h>
#include <sourcemeta/jsontoolkit/jsonschema.h>

#include "jsonschema_transform_rules.h"

TEST(JSONSchema_transform_rule, instances_of_same_rule_are_equal) {
const ExampleRule1 foo{};
const ExampleRule1 bar{};
EXPECT_EQ(foo, bar);
}

TEST(JSONSchema_transform_rule,
instances_of_same_rule_are_equal_with_unique_ptr) {
const std::unique_ptr<ExampleRule1> foo{};
const std::unique_ptr<ExampleRule1> bar{};
EXPECT_EQ(foo, bar);
}

TEST(JSONSchema_transform_rule, instances_of_different_rules_are_different) {
const ExampleRule1 foo{};
const ExampleRule2 bar{};
EXPECT_NE(foo, bar);
}

TEST(JSONSchema_transform_rule, rule_message) {
const ExampleRule7 rule{};
EXPECT_EQ(rule.message(), "My custom message");
}
Loading

10 comments on commit 0fc100e

@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: 0fc100e Previous: f285701 Ratio
JSON_Array_Of_Objects_Unique 401.88197544642276 ns/iter 406.56563809972334 ns/iter 0.99
JSON_Parse_1 78538.92857142394 ns/iter 82787.30413821143 ns/iter 0.95
JSON_Fast_Hash_Helm_Chart_Lock 52.29587999999694 ns/iter 56.196219999992536 ns/iter 0.93
JSON_Equality_Helm_Chart_Lock 186.70782917032912 ns/iter 192.49284754399648 ns/iter 0.97
JSON_String_Equal/10 8.976952192067394 ns/iter 9.23495486948791 ns/iter 0.97
JSON_String_Equal/100 9.908562499997942 ns/iter 10.460860937499206 ns/iter 0.95
JSON_String_Equal_Small_By_Perfect_Hash/10 2.167800000000142 ns/iter 2.1950661805859735 ns/iter 0.99
JSON_String_Equal_Small_By_Runtime_Perfect_Hash/10 14.864781150456912 ns/iter 15.091734374999632 ns/iter 0.98
JSON_String_Fast_Hash/10 3.095317410714163 ns/iter 3.1025859110234575 ns/iter 1.00
JSON_String_Fast_Hash/100 3.096720535713717 ns/iter 3.112848660714564 ns/iter 0.99
JSON_String_Key_Hash/10 7.722917376236031 ns/iter 7.59923701964758 ns/iter 1.02
JSON_String_Key_Hash/100 4.0255916143317 ns/iter 4.070101525125123 ns/iter 0.99
JSON_Object_Defines_Miss_Same_Length 3.7213998147832523 ns/iter 3.745359100455044 ns/iter 0.99
JSON_Object_Defines_Miss_Too_Small 3.724421779063675 ns/iter 3.75414106472489 ns/iter 0.99
JSON_Object_Defines_Miss_Too_Large 4.959200000000692 ns/iter 5.060330357143324 ns/iter 0.98
Pointer_Object_Traverse 53.015879999998106 ns/iter 52.10233928571435 ns/iter 1.02
Pointer_Object_Try_Traverse 74.40119419643209 ns/iter 77.32294744094332 ns/iter 0.96
Pointer_Push_Back_Pointer_To_Weak_Pointer 179.62507676062816 ns/iter 163.8452008928632 ns/iter 1.10

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/llvm)

Benchmark suite Current: 0fc100e Previous: f285701 Ratio
JSON_Array_Of_Objects_Unique 439.77158500727654 ns/iter 445.0056048734423 ns/iter 0.99
JSON_Parse_1 30291.931003038437 ns/iter 30949.60519469127 ns/iter 0.98
JSON_Fast_Hash_Helm_Chart_Lock 67.783133875627 ns/iter 67.74484226855972 ns/iter 1.00
JSON_Equality_Helm_Chart_Lock 168.04748420794564 ns/iter 155.73922495755204 ns/iter 1.08
JSON_String_Equal/10 7.467981467488906 ns/iter 5.910640450745298 ns/iter 1.26
JSON_String_Equal/100 8.080933156746736 ns/iter 6.5390087591599055 ns/iter 1.24
JSON_String_Equal_Small_By_Perfect_Hash/10 0.9351357850023496 ns/iter 0.936587445790056 ns/iter 1.00
JSON_String_Equal_Small_By_Runtime_Perfect_Hash/10 14.605345327598277 ns/iter 14.599408474021196 ns/iter 1.00
JSON_String_Fast_Hash/10 2.799304468303211 ns/iter 2.7960212539083047 ns/iter 1.00
JSON_String_Fast_Hash/100 2.798872040520124 ns/iter 2.7960857717781646 ns/iter 1.00
JSON_String_Key_Hash/10 2.6970536149416517 ns/iter 2.708889298216427 ns/iter 1.00
JSON_String_Key_Hash/100 2.1791592128845587 ns/iter 2.1786488507747745 ns/iter 1.00
JSON_Object_Defines_Miss_Same_Length 3.7373141047414316 ns/iter 3.738419472384038 ns/iter 1.00
JSON_Object_Defines_Miss_Too_Small 3.735412365175254 ns/iter 3.7550352171921983 ns/iter 0.99
JSON_Object_Defines_Miss_Too_Large 3.7335068125809725 ns/iter 3.742029190583183 ns/iter 1.00
Pointer_Object_Traverse 43.88805912755642 ns/iter 44.01402073901948 ns/iter 1.00
Pointer_Object_Try_Traverse 52.58786625380949 ns/iter 52.66665491857795 ns/iter 1.00
Pointer_Push_Back_Pointer_To_Weak_Pointer 289.04949606517044 ns/iter 289.71550331059603 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 (windows/msvc)

Benchmark suite Current: 0fc100e Previous: f285701 Ratio
JSON_Array_Of_Objects_Unique 407.4786395614008 ns/iter 406.56563809972334 ns/iter 1.00
JSON_Parse_1 80670.99330356494 ns/iter 82787.30413821143 ns/iter 0.97
JSON_Fast_Hash_Helm_Chart_Lock 53.36540000000696 ns/iter 56.196219999992536 ns/iter 0.95
JSON_Equality_Helm_Chart_Lock 195.54984781697777 ns/iter 192.49284754399648 ns/iter 1.02
JSON_String_Equal/10 8.984975852744938 ns/iter 9.23495486948791 ns/iter 0.97
JSON_String_Equal/100 9.952960937498647 ns/iter 10.460860937499206 ns/iter 0.95
JSON_String_Equal_Small_By_Perfect_Hash/10 2.167079375000114 ns/iter 2.1950661805859735 ns/iter 0.99
JSON_String_Equal_Small_By_Runtime_Perfect_Hash/10 15.422127575296935 ns/iter 15.091734374999632 ns/iter 1.02
JSON_String_Fast_Hash/10 3.09363526785741 ns/iter 3.1025859110234575 ns/iter 1.00
JSON_String_Fast_Hash/100 3.0997607142855896 ns/iter 3.112848660714564 ns/iter 1.00
JSON_String_Key_Hash/10 7.4900904017852605 ns/iter 7.59923701964758 ns/iter 0.99
JSON_String_Key_Hash/100 4.024486033972405 ns/iter 4.070101525125123 ns/iter 0.99
JSON_Object_Defines_Miss_Same_Length 3.726584993345303 ns/iter 3.745359100455044 ns/iter 0.99
JSON_Object_Defines_Miss_Too_Small 3.7175394576471685 ns/iter 3.75414106472489 ns/iter 0.99
JSON_Object_Defines_Miss_Too_Large 4.966143000000329 ns/iter 5.060330357143324 ns/iter 0.98
Pointer_Object_Traverse 52.061214285714634 ns/iter 52.10233928571435 ns/iter 1.00
Pointer_Object_Try_Traverse 74.50947321428559 ns/iter 77.32294744094332 ns/iter 0.96
Pointer_Push_Back_Pointer_To_Weak_Pointer 179.0107218087424 ns/iter 163.8452008928632 ns/iter 1.09

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: 0fc100e Previous: f285701 Ratio
JSON_Array_Of_Objects_Unique 363.41164244814377 ns/iter 361.96795413338793 ns/iter 1.00
JSON_Parse_1 29055.4502328631 ns/iter 24329.13559322268 ns/iter 1.19
JSON_Fast_Hash_Helm_Chart_Lock 65.79624330249891 ns/iter 53.552792776483045 ns/iter 1.23
JSON_Equality_Helm_Chart_Lock 173.45601440658496 ns/iter 145.67581133132254 ns/iter 1.19
JSON_String_Equal/10 10.207719155264893 ns/iter 8.420756889290356 ns/iter 1.21
JSON_String_Equal/100 6.5439845148480185 ns/iter 6.854472796559273 ns/iter 0.95
JSON_String_Equal_Small_By_Perfect_Hash/10 0.3522633799746671 ns/iter 0.4502963139256893 ns/iter 0.78
JSON_String_Equal_Small_By_Runtime_Perfect_Hash/10 3.2096392036960513 ns/iter 4.242059817769369 ns/iter 0.76
JSON_String_Fast_Hash/10 1.7826277155249033 ns/iter 2.268353871086957 ns/iter 0.79
JSON_String_Fast_Hash/100 2.33328693390037 ns/iter 2.5656718695358802 ns/iter 0.91
JSON_String_Key_Hash/10 1.6624549268702091 ns/iter 1.6007783716260415 ns/iter 1.04
JSON_String_Key_Hash/100 1.5920918900570658 ns/iter 1.5290090041583166 ns/iter 1.04
JSON_Object_Defines_Miss_Same_Length 2.911265741243053 ns/iter 2.735547293029214 ns/iter 1.06
JSON_Object_Defines_Miss_Too_Small 3.0991872547439208 ns/iter 2.822075821364744 ns/iter 1.10
JSON_Object_Defines_Miss_Too_Large 2.971092683869107 ns/iter 2.6825110258742466 ns/iter 1.11
Pointer_Object_Traverse 23.5656917099432 ns/iter 19.54114612331589 ns/iter 1.21
Pointer_Object_Try_Traverse 32.6011158752732 ns/iter 27.187477912107497 ns/iter 1.20
Pointer_Push_Back_Pointer_To_Weak_Pointer 258.4030995687991 ns/iter 213.0609785973912 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 (linux/llvm)

Benchmark suite Current: 0fc100e Previous: f285701 Ratio
JSON_Array_Of_Objects_Unique 444.6831491422736 ns/iter 445.0056048734423 ns/iter 1.00
JSON_Parse_1 30016.879087354257 ns/iter 30949.60519469127 ns/iter 0.97
JSON_Fast_Hash_Helm_Chart_Lock 67.82667666639489 ns/iter 67.74484226855972 ns/iter 1.00
JSON_Equality_Helm_Chart_Lock 151.04578972679244 ns/iter 155.73922495755204 ns/iter 0.97
JSON_String_Equal/10 6.2263231512855315 ns/iter 5.910640450745298 ns/iter 1.05
JSON_String_Equal/100 6.812590101068144 ns/iter 6.5390087591599055 ns/iter 1.04
JSON_String_Equal_Small_By_Perfect_Hash/10 0.9350363448037401 ns/iter 0.936587445790056 ns/iter 1.00
JSON_String_Equal_Small_By_Runtime_Perfect_Hash/10 10.263595053600774 ns/iter 14.599408474021196 ns/iter 0.70
JSON_String_Fast_Hash/10 2.80049482658076 ns/iter 2.7960212539083047 ns/iter 1.00
JSON_String_Fast_Hash/100 2.798022508565562 ns/iter 2.7960857717781646 ns/iter 1.00
JSON_String_Key_Hash/10 2.178486488163509 ns/iter 2.708889298216427 ns/iter 0.80
JSON_String_Key_Hash/100 2.1793364583699812 ns/iter 2.1786488507747745 ns/iter 1.00
JSON_Object_Defines_Miss_Same_Length 3.7699103649701065 ns/iter 3.738419472384038 ns/iter 1.01
JSON_Object_Defines_Miss_Too_Small 3.733918259749967 ns/iter 3.7550352171921983 ns/iter 0.99
JSON_Object_Defines_Miss_Too_Large 3.7409215044847275 ns/iter 3.742029190583183 ns/iter 1.00
Pointer_Object_Traverse 44.511045337286205 ns/iter 44.01402073901948 ns/iter 1.01
Pointer_Object_Try_Traverse 52.634378553755305 ns/iter 52.66665491857795 ns/iter 1.00
Pointer_Push_Back_Pointer_To_Weak_Pointer 289.3941212504647 ns/iter 289.71550331059603 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 (linux/gcc)

Benchmark suite Current: 0fc100e Previous: f285701 Ratio
Pointer_Object_Traverse 45.36137198550726 ns/iter 46.30152205045735 ns/iter 0.98
Pointer_Object_Try_Traverse 23.38338967886053 ns/iter 23.357628057749224 ns/iter 1.00
Pointer_Push_Back_Pointer_To_Weak_Pointer 144.75868587545816 ns/iter 144.71220300476529 ns/iter 1.00
JSON_Array_Of_Objects_Unique 409.47646162791455 ns/iter 421.7987507663135 ns/iter 0.97
JSON_Parse_1 33470.009848917194 ns/iter 33452.80865701759 ns/iter 1.00
JSON_Fast_Hash_Helm_Chart_Lock 64.76877476558462 ns/iter 65.0593951850862 ns/iter 1.00
JSON_Equality_Helm_Chart_Lock 142.22456885646173 ns/iter 144.4246132804019 ns/iter 0.98
JSON_String_Equal/10 5.991679451988232 ns/iter 5.991415797851993 ns/iter 1.00
JSON_String_Equal/100 6.756267730009827 ns/iter 6.621908568255762 ns/iter 1.02
JSON_String_Equal_Small_By_Perfect_Hash/10 0.6463200041491756 ns/iter 0.6266144760299274 ns/iter 1.03
JSON_String_Equal_Small_By_Runtime_Perfect_Hash/10 14.295952583763107 ns/iter 14.296440776228257 ns/iter 1.00
JSON_String_Fast_Hash/10 2.256779073455568 ns/iter 2.2531939887434875 ns/iter 1.00
JSON_String_Fast_Hash/100 2.255833224463305 ns/iter 2.2539410345453286 ns/iter 1.00
JSON_String_Key_Hash/10 1.983778129644623 ns/iter 1.9960073950856352 ns/iter 0.99
JSON_String_Key_Hash/100 1.6727201274998738 ns/iter 1.6725423411864238 ns/iter 1.00
JSON_Object_Defines_Miss_Same_Length 2.4893822332995117 ns/iter 2.487778190919151 ns/iter 1.00
JSON_Object_Defines_Miss_Too_Small 3.1285598739473053 ns/iter 3.1082686960864323 ns/iter 1.01
JSON_Object_Defines_Miss_Too_Large 2.7999866430787907 ns/iter 2.7979304631773525 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: 0fc100e Previous: f285701 Ratio
JSON_Array_Of_Objects_Unique 265.48373806171037 ns/iter 216.21509594941247 ns/iter 1.23
JSON_Parse_1 27284.843079793613 ns/iter 23828.67190302635 ns/iter 1.15
JSON_Fast_Hash_Helm_Chart_Lock 26.73470523229167 ns/iter 24.218518155859254 ns/iter 1.10
JSON_Equality_Helm_Chart_Lock 128.4278609445176 ns/iter 117.3557015951958 ns/iter 1.09
JSON_String_Equal/10 6.0044203344483105 ns/iter 5.579267215545694 ns/iter 1.08
JSON_String_Equal/100 5.756198711807972 ns/iter 5.237618055546419 ns/iter 1.10
JSON_String_Equal_Small_By_Perfect_Hash/10 0.8669589993505308 ns/iter 0.7734738449834633 ns/iter 1.12
JSON_String_Equal_Small_By_Runtime_Perfect_Hash/10 3.403854707406344 ns/iter 2.99620526250668 ns/iter 1.14
JSON_String_Fast_Hash/10 2.155209136543456 ns/iter 1.955507152007 ns/iter 1.10
JSON_String_Fast_Hash/100 2.1927889200459236 ns/iter 2.024872705958354 ns/iter 1.08
JSON_String_Key_Hash/10 1.5866654329945047 ns/iter 1.3100397677736282 ns/iter 1.21
JSON_String_Key_Hash/100 1.953092742825081 ns/iter 1.782364311081305 ns/iter 1.10
JSON_Object_Defines_Miss_Same_Length 1.83401508070085 ns/iter 1.796509234033133 ns/iter 1.02
JSON_Object_Defines_Miss_Too_Small 2.24089132118328 ns/iter 1.9528465300801838 ns/iter 1.15
JSON_Object_Defines_Miss_Too_Large 1.9047236451432341 ns/iter 1.7858692632762243 ns/iter 1.07
Pointer_Object_Traverse 55.845487028638665 ns/iter 53.20884450834256 ns/iter 1.05
Pointer_Object_Try_Traverse 39.965027060481205 ns/iter 36.94768250329327 ns/iter 1.08
Pointer_Push_Back_Pointer_To_Weak_Pointer 182.07918926054853 ns/iter 165.28141894184168 ns/iter 1.10

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: 0fc100e Previous: f285701 Ratio
JSON_Array_Of_Objects_Unique 395.1483350499182 ns/iter 361.96795413338793 ns/iter 1.09
JSON_Parse_1 24974.770402838567 ns/iter 24329.13559322268 ns/iter 1.03
JSON_Fast_Hash_Helm_Chart_Lock 53.1265033383471 ns/iter 53.552792776483045 ns/iter 0.99
JSON_Equality_Helm_Chart_Lock 135.810214879401 ns/iter 145.67581133132254 ns/iter 0.93
JSON_String_Equal/10 8.864542148652852 ns/iter 8.420756889290356 ns/iter 1.05
JSON_String_Equal/100 7.7508701684388885 ns/iter 6.854472796559273 ns/iter 1.13
JSON_String_Equal_Small_By_Perfect_Hash/10 0.3799838229984226 ns/iter 0.4502963139256893 ns/iter 0.84
JSON_String_Equal_Small_By_Runtime_Perfect_Hash/10 3.4366952710940297 ns/iter 4.242059817769369 ns/iter 0.81
JSON_String_Fast_Hash/10 1.8604538086001505 ns/iter 2.268353871086957 ns/iter 0.82
JSON_String_Fast_Hash/100 2.13902548909534 ns/iter 2.5656718695358802 ns/iter 0.83
JSON_String_Key_Hash/10 1.478180025600961 ns/iter 1.6007783716260415 ns/iter 0.92
JSON_String_Key_Hash/100 1.517665669829939 ns/iter 1.5290090041583166 ns/iter 0.99
JSON_Object_Defines_Miss_Same_Length 2.982966507113585 ns/iter 2.735547293029214 ns/iter 1.09
JSON_Object_Defines_Miss_Too_Small 2.6861336496986756 ns/iter 2.822075821364744 ns/iter 0.95
JSON_Object_Defines_Miss_Too_Large 2.5021834683255872 ns/iter 2.6825110258742466 ns/iter 0.93
Pointer_Object_Traverse 17.031074076304186 ns/iter 19.54114612331589 ns/iter 0.87
Pointer_Object_Try_Traverse 25.287444168734403 ns/iter 27.187477912107497 ns/iter 0.93
Pointer_Push_Back_Pointer_To_Weak_Pointer 201.2126501374894 ns/iter 213.0609785973912 ns/iter 0.94

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: 0fc100e Previous: f285701 Ratio
Pointer_Object_Traverse 45.944966357088454 ns/iter 46.30152205045735 ns/iter 0.99
Pointer_Object_Try_Traverse 23.353982525499525 ns/iter 23.357628057749224 ns/iter 1.00
Pointer_Push_Back_Pointer_To_Weak_Pointer 151.646416343823 ns/iter 144.71220300476529 ns/iter 1.05
JSON_Array_Of_Objects_Unique 409.4892997797525 ns/iter 421.7987507663135 ns/iter 0.97
JSON_Parse_1 33645.466469185674 ns/iter 33452.80865701759 ns/iter 1.01
JSON_Fast_Hash_Helm_Chart_Lock 70.69618569734308 ns/iter 65.0593951850862 ns/iter 1.09
JSON_Equality_Helm_Chart_Lock 143.03748264502008 ns/iter 144.4246132804019 ns/iter 0.99
JSON_String_Equal/10 5.992041300778191 ns/iter 5.991415797851993 ns/iter 1.00
JSON_String_Equal/100 6.617679268281156 ns/iter 6.621908568255762 ns/iter 1.00
JSON_String_Equal_Small_By_Perfect_Hash/10 0.6250877061246954 ns/iter 0.6266144760299274 ns/iter 1.00
JSON_String_Equal_Small_By_Runtime_Perfect_Hash/10 14.28687224230198 ns/iter 14.296440776228257 ns/iter 1.00
JSON_String_Fast_Hash/10 2.259285654091427 ns/iter 2.2531939887434875 ns/iter 1.00
JSON_String_Fast_Hash/100 2.2532145160237107 ns/iter 2.2539410345453286 ns/iter 1.00
JSON_String_Key_Hash/10 1.9841745110967128 ns/iter 1.9960073950856352 ns/iter 0.99
JSON_String_Key_Hash/100 1.6715523767793665 ns/iter 1.6725423411864238 ns/iter 1.00
JSON_Object_Defines_Miss_Same_Length 2.486002855049122 ns/iter 2.487778190919151 ns/iter 1.00
JSON_Object_Defines_Miss_Too_Small 3.1217560007426135 ns/iter 3.1082686960864323 ns/iter 1.00
JSON_Object_Defines_Miss_Too_Large 2.8035153017620473 ns/iter 2.7979304631773525 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: 0fc100e Previous: f285701 Ratio
JSON_Array_Of_Objects_Unique 225.53524386811998 ns/iter 216.21509594941247 ns/iter 1.04
JSON_Parse_1 27628.742809797695 ns/iter 23828.67190302635 ns/iter 1.16
JSON_Fast_Hash_Helm_Chart_Lock 25.135020231942192 ns/iter 24.218518155859254 ns/iter 1.04
JSON_Equality_Helm_Chart_Lock 118.70276494535462 ns/iter 117.3557015951958 ns/iter 1.01
JSON_String_Equal/10 5.74125390298375 ns/iter 5.579267215545694 ns/iter 1.03
JSON_String_Equal/100 5.6180782925244666 ns/iter 5.237618055546419 ns/iter 1.07
JSON_String_Equal_Small_By_Perfect_Hash/10 0.8840167728124099 ns/iter 0.7734738449834633 ns/iter 1.14
JSON_String_Equal_Small_By_Runtime_Perfect_Hash/10 3.090206258294578 ns/iter 2.99620526250668 ns/iter 1.03
JSON_String_Fast_Hash/10 2.014704005178141 ns/iter 1.955507152007 ns/iter 1.03
JSON_String_Fast_Hash/100 1.9870587616447017 ns/iter 2.024872705958354 ns/iter 0.98
JSON_String_Key_Hash/10 1.3433741904770458 ns/iter 1.3100397677736282 ns/iter 1.03
JSON_String_Key_Hash/100 1.7411116237888928 ns/iter 1.782364311081305 ns/iter 0.98
JSON_Object_Defines_Miss_Same_Length 1.756216489417419 ns/iter 1.796509234033133 ns/iter 0.98
JSON_Object_Defines_Miss_Too_Small 1.9377998265711915 ns/iter 1.9528465300801838 ns/iter 0.99
JSON_Object_Defines_Miss_Too_Large 1.7710241638774564 ns/iter 1.7858692632762243 ns/iter 0.99
Pointer_Object_Traverse 52.390000805969215 ns/iter 53.20884450834256 ns/iter 0.98
Pointer_Object_Try_Traverse 35.84086767736914 ns/iter 36.94768250329327 ns/iter 0.97
Pointer_Push_Back_Pointer_To_Weak_Pointer 161.9926789795267 ns/iter 165.28141894184168 ns/iter 0.98

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

Please sign in to comment.