Skip to content

Commit 83a199d

Browse files
committed
Add a microbenchmark for validator creation.
1 parent 6142ddc commit 83a199d

File tree

2 files changed

+24
-6
lines changed

2 files changed

+24
-6
lines changed
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
from pyperf import Runner
2+
3+
from jsonschema import Draft202012Validator
4+
5+
schema = {
6+
"type": "array",
7+
"minLength": 1,
8+
"maxLength": 1,
9+
"items": {"type": "integer"}
10+
}
11+
12+
13+
if __name__ == "__main__":
14+
Runner().bench_func("validator creation", Draft202012Validator, schema)

tox.ini

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,9 @@ skipsdist = True
1414
changedir = {envtmpdir}
1515
passenv = CI, GITHUB_STEP_SUMMARY, PYTHONUTF8
1616
setenv =
17+
PIP_DISABLE_PIP_VERSION_CHECK = 1
18+
PIP_QUIET = 1
19+
1720
JSON_SCHEMA_TEST_SUITE = {toxinidir}/json
1821

1922
coverage,ghcoverage: MAYBE_COVERAGE=coverage run -m
@@ -24,9 +27,9 @@ allowlist_externals =
2427
mkdir
2528
sh
2629
commands =
27-
noextra: {envpython} -m pip install --disable-pip-version-check {toxinidir}
28-
format,perf,perfsuite: {envpython} -m pip install --disable-pip-version-check '{toxinidir}[format]'
29-
formatnongpl: {envpython} -m pip install --disable-pip-version-check '{toxinidir}[format-nongpl]'
30+
noextra: {envpython} -m pip install {toxinidir}
31+
format,perf: {envpython} -m pip install '{toxinidir}[format]'
32+
formatnongpl: {envpython} -m pip install '{toxinidir}[format-nongpl]'
3033

3134
audit: {envpython} -m pip_audit
3235
audit-formatnongpl: {envpython} -m piplicenses {posargs} --ignore-packages pip-requirements-parser pip_audit pip-api --allow-only="Apache Software License;ISC License (ISCL);MIT License;BSD License;Mozilla Public License 2.0 (MPL 2.0)"
@@ -40,15 +43,16 @@ commands =
4043
coverage: {envpython} -m coverage html --directory={envtmpdir}/htmlcov
4144
ghcoverage: sh {toxinidir}/.github/coverage.sh "{envpython}"
4245

43-
perf: {envpython} {toxinidir}/jsonschema/benchmarks/issue232.py --inherit-environ JSON_SCHEMA_TEST_SUITE {posargs:--output {envtmpdir}/bench-issue232.json}
44-
perfsuite: {envpython} {toxinidir}/jsonschema/benchmarks/json_schema_test_suite.py --inherit-environ JSON_SCHEMA_TEST_SUITE {posargs:--output {envtmpdir}/bench-json_schema_test_suite.json}
46+
perf-create: {envpython} {toxinidir}/jsonschema/benchmarks/validator_creation.py {posargs:--output {envtmpdir}/bench-create.json}
47+
perf-232: {envpython} {toxinidir}/jsonschema/benchmarks/issue232.py {posargs:--output {envtmpdir}/bench-issue232.json}
48+
perf-suite: {envpython} {toxinidir}/jsonschema/benchmarks/json_schema_test_suite.py --inherit-environ JSON_SCHEMA_TEST_SUITE {posargs:--output {envtmpdir}/bench-json_schema_test_suite.json}
4549
deps =
4650
audit: pip-audit
4751
audit-formatnongpl: pip-licenses
4852

4953
build: build
5054

51-
perf,perfsuite: pyperf
55+
perf: pyperf
5256

5357
tests,coverage,ghcoverage: twisted
5458

0 commit comments

Comments
 (0)