diff --git a/tests/benchmarks/test_compilation.py b/tests/benchmarks/test_compilation.py index a7a10015ef..dbea810239 100644 --- a/tests/benchmarks/test_compilation.py +++ b/tests/benchmarks/test_compilation.py @@ -4,11 +4,20 @@ from reflex.components.component import Component +def import_templates(): + # Importing the templates module to avoid the import time in the benchmark + import reflex.compiler.templates # noqa: F401 + + def test_compile_page(evaluated_page: Component, benchmark: BenchmarkFixture): + import_templates() + benchmark(lambda: _compile_page(evaluated_page, None)) def test_compile_stateful(evaluated_page: Component, benchmark: BenchmarkFixture): + import_templates() + benchmark(lambda: _compile_stateful_components([evaluated_page]))