move benchmarks and add some more (#4758)
* move benchmarks and add some more * change key and paths * parametrize tests * more specific ignore * rename fixture * remove previous file * add tests for _compile_stateful_components
This commit is contained in:
parent
19f40745f8
commit
d0199a326f
2
.github/workflows/performance.yml
vendored
2
.github/workflows/performance.yml
vendored
@ -31,4 +31,4 @@ jobs:
|
||||
uses: CodSpeedHQ/action@v3
|
||||
with:
|
||||
token: ${{ secrets.CODSPEED_TOKEN }}
|
||||
run: poetry run pytest benchmarks/test_evaluate.py --codspeed
|
||||
run: poetry run pytest tests/benchmarks --codspeed
|
||||
|
@ -102,6 +102,7 @@ lint.pydocstyle.convention = "google"
|
||||
"*/blank.py" = ["I001"]
|
||||
|
||||
[tool.pytest.ini_options]
|
||||
filterwarnings = "ignore:fields may not start with an underscore:RuntimeWarning"
|
||||
asyncio_default_fixture_loop_scope = "function"
|
||||
asyncio_mode = "auto"
|
||||
|
||||
|
0
tests/benchmarks/__init__.py
Normal file
0
tests/benchmarks/__init__.py
Normal file
3
tests/benchmarks/conftest.py
Normal file
3
tests/benchmarks/conftest.py
Normal file
@ -0,0 +1,3 @@
|
||||
from .fixtures import evaluated_page
|
||||
|
||||
__all__ = ["evaluated_page"]
|
@ -216,7 +216,14 @@ def side_bar():
|
||||
LOREM_IPSUM = "Lorem ipsum dolor sit amet, dolor ut dolore pariatur aliqua enim tempor sed. Labore excepteur sed exercitation. Ullamco aliquip lorem sunt enim in incididunt. Magna anim officia sint cillum labore. Ut eu non dolore minim nostrud magna eu, aute ex in incididunt irure eu. Fugiat et magna magna est excepteur eiusmod minim. Quis eiusmod et non pariatur dolor veniam incididunt, eiusmod irure enim sed dolor lorem pariatur do. Occaecat duis irure excepteur dolore. Proident ut laborum pariatur sit sit, nisi nostrud voluptate magna commodo laborum esse velit. Voluptate non minim deserunt adipiscing irure deserunt cupidatat. Laboris veniam commodo incididunt veniam lorem occaecat, fugiat ipsum dolor cupidatat. Ea officia sed eu excepteur culpa adipiscing, tempor consectetur ullamco eu. Anim ex proident nulla sunt culpa, voluptate veniam proident est adipiscing sint elit velit. Laboris adipiscing est culpa cillum magna. Sit veniam nulla nulla, aliqua eiusmod commodo lorem cupidatat commodo occaecat. Fugiat cillum dolor incididunt mollit eiusmod sint. Non lorem dolore labore excepteur minim laborum sed. Irure nisi do lorem nulla sunt commodo, deserunt quis mollit consectetur minim et esse est, proident nostrud officia enim sed reprehenderit. Magna cillum consequat aute reprehenderit duis sunt ullamco. Labore qui mollit voluptate. Duis dolor sint aute amet aliquip officia, est non mollit tempor enim quis fugiat, eu do culpa consectetur magna. Do ullamco aliqua voluptate culpa excepteur reprehenderit reprehenderit. Occaecat nulla sit est magna. Deserunt ea voluptate veniam cillum. Amet cupidatat duis est tempor fugiat ex eu, officia est sunt consectetur labore esse exercitation. Nisi cupidatat irure est nisi. Officia amet eu veniam reprehenderit. In amet incididunt tempor commodo ea labore. Mollit dolor aliquip excepteur, voluptate aute occaecat id officia proident. Ullamco est amet tempor. Proident aliquip proident mollit do aliquip ipsum, culpa quis aute id irure. Velit excepteur cillum cillum ut cupidatat. Occaecat qui elit esse nulla minim. Consequat velit id ad pariatur tempor. Eiusmod deserunt aliqua ex sed quis non. Dolor sint commodo ex in deserunt nostrud excepteur, pariatur ex aliqua anim adipiscing amet proident. Laboris eu laborum magna lorem ipsum fugiat velit."
|
||||
|
||||
|
||||
def complicated_page():
|
||||
def _simple_page():
|
||||
return rx.box(
|
||||
rx.heading("Simple Page", size="1"),
|
||||
rx.text(LOREM_IPSUM),
|
||||
)
|
||||
|
||||
|
||||
def _complicated_page():
|
||||
return rx.hstack(
|
||||
side_bar(),
|
||||
rx.box(
|
||||
@ -226,6 +233,6 @@ def complicated_page():
|
||||
)
|
||||
|
||||
|
||||
@pytest.mark.benchmark
|
||||
def test_component_init():
|
||||
complicated_page()
|
||||
@pytest.fixture(params=[_simple_page, _complicated_page])
|
||||
def evaluated_page(request):
|
||||
return request.param()
|
18
tests/benchmarks/test_compilation.py
Normal file
18
tests/benchmarks/test_compilation.py
Normal file
@ -0,0 +1,18 @@
|
||||
import pytest
|
||||
|
||||
from reflex.compiler.compiler import _compile_page, _compile_stateful_components
|
||||
|
||||
|
||||
@pytest.mark.benchmark
|
||||
def test_compile_page(evaluated_page):
|
||||
_compile_page(evaluated_page, None)
|
||||
|
||||
|
||||
@pytest.mark.benchmark
|
||||
def test_compile_stateful(evaluated_page):
|
||||
_compile_stateful_components([evaluated_page])
|
||||
|
||||
|
||||
@pytest.mark.benchmark
|
||||
def test_get_all_imports(evaluated_page):
|
||||
evaluated_page._get_all_imports()
|
9
tests/benchmarks/test_evaluate.py
Normal file
9
tests/benchmarks/test_evaluate.py
Normal file
@ -0,0 +1,9 @@
|
||||
import pytest
|
||||
|
||||
from .fixtures import _complicated_page, _simple_page
|
||||
|
||||
|
||||
@pytest.mark.benchmark
|
||||
@pytest.mark.parametrize("page", [_simple_page, _complicated_page])
|
||||
def test_evaluate_page(page):
|
||||
page()
|
Loading…
Reference in New Issue
Block a user