瀏覽代碼

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
Thomas Brandého 3 月之前
父節點
當前提交
d0199a326f

+ 1 - 1
.github/workflows/performance.yml

@@ -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

+ 1 - 0
pyproject.toml

@@ -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 - 0
tests/benchmarks/__init__.py


+ 3 - 0
tests/benchmarks/conftest.py

@@ -0,0 +1,3 @@
+from .fixtures import evaluated_page
+
+__all__ = ["evaluated_page"]

文件差異過大導致無法顯示
+ 0 - 0
tests/benchmarks/fixtures.py


+ 18 - 0
tests/benchmarks/test_compilation.py

@@ -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 - 0
tests/benchmarks/test_evaluate.py

@@ -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()

部分文件因文件數量過多而無法顯示