⚝
One Hat Cyber Team
⚝
Your IP:
216.73.216.144
Server IP:
157.245.143.252
Server:
Linux www 6.11.0-9-generic #9-Ubuntu SMP PREEMPT_DYNAMIC Mon Oct 14 13:19:59 UTC 2024 x86_64
Server Software:
nginx/1.26.0
PHP Version:
8.3.11
Buat File
|
Buat Folder
Eksekusi
Dir :
~
/
lib
/
python3
/
dist-packages
/
jsonschema
/
benchmarks
/
View File Name :
unused_registry.py
""" An unused schema registry should not cause slower validation. "Unused" here means one where no reference resolution is occurring anyhow. See https://github.com/python-jsonschema/jsonschema/issues/1088. """ from pyperf import Runner from referencing import Registry from referencing.jsonschema import DRAFT201909 from jsonschema import Draft201909Validator registry = Registry().with_resource( "urn:example:foo", DRAFT201909.create_resource({}) ) schema = {"$ref": "https://json-schema.org/draft/2019-09/schema"} instance = {"maxLength": 4} no_registry = Draft201909Validator(schema) with_useless_registry = Draft201909Validator(schema, registry=registry) if __name__ == "__main__": runner = Runner() runner.bench_func( "no registry", lambda: no_registry.is_valid(instance), ) runner.bench_func( "useless registry", lambda: with_useless_registry.is_valid(instance), )