Skip to content

Commit c42f1e1

Browse files
committed
Add pytest-benchmark and port introspectionFromSchema-benchmark.js
1 parent da6d040 commit c42f1e1

File tree

8 files changed

+13206
-78
lines changed

8 files changed

+13206
-78
lines changed

poetry.lock

+23-77
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pyproject.toml

+1
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ python = "^3.6"
3333
[tool.poetry.dev-dependencies]
3434
pytest = "^5"
3535
pytest-asyncio = ">=0.10"
36+
pytest-benchmark = "^3.2"
3637
pytest-cov = "^2.7"
3738
pytest-describe = ">=0.12"
3839
pyyaml = "^5.1"

setup.cfg

+5
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,8 @@ python-tag = py3
33

44
[aliases]
55
test = pytest
6+
7+
[tool:pytest]
8+
# Only run benchmarks as tests.
9+
# To actually run the benchmarks, use --benchmark-enable on the command line.
10+
addopts = --benchmark-disable

tests/benchmarks/__init__.py

Whitespace-only changes.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
from graphql import build_schema, parse, execute
2+
from graphql.utilities import introspection_query
3+
4+
# noinspection PyUnresolvedReferences
5+
from ..fixtures import big_schema_sdl # noqa: F401
6+
7+
8+
def test_executing_introspection_query(benchmark, big_schema_sdl): # noqa: F811
9+
schema = build_schema(big_schema_sdl)
10+
query = parse(introspection_query.get_introspection_query())
11+
result = benchmark(lambda: execute(schema, query))
12+
assert result.errors is None

tests/fixtures/__init__.py

+6-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
from pytest import fixture # type: ignore
66

7-
__all__ = ["kitchen_sink_query", "kitchen_sink_sdl"]
7+
__all__ = ["kitchen_sink_query", "kitchen_sink_sdl", "big_schema_sdl"]
88

99

1010
def read_graphql(name):
@@ -20,3 +20,8 @@ def kitchen_sink_query():
2020
@fixture(scope="module")
2121
def kitchen_sink_sdl():
2222
return read_graphql("schema_kitchen_sink")
23+
24+
25+
@fixture(scope="module")
26+
def big_schema_sdl():
27+
return read_graphql("github_schema")

0 commit comments

Comments
 (0)