reflex/tests/benchmarks/test_compilation.py
Khaleel Al-Adhami d79366d8b2
benchmark experimentation (#4811)
* benchmark experimentation

* do the same for test_evaluate_page

* import templates beforehands

* add auto reload

* disable extensions
2025-02-12 14:51:58 -08:00

26 lines
817 B
Python

from pytest_codspeed import BenchmarkFixture
from reflex.compiler.compiler import _compile_page, _compile_stateful_components
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]))
def test_get_all_imports(evaluated_page: Component, benchmark: BenchmarkFixture):
benchmark(lambda: evaluated_page._get_all_imports())