test_compilation.py 817 B

12345678910111213141516171819202122232425
  1. from pytest_codspeed import BenchmarkFixture
  2. from reflex.compiler.compiler import _compile_page, _compile_stateful_components
  3. from reflex.components.component import Component
  4. def import_templates():
  5. # Importing the templates module to avoid the import time in the benchmark
  6. import reflex.compiler.templates # noqa: F401
  7. def test_compile_page(evaluated_page: Component, benchmark: BenchmarkFixture):
  8. import_templates()
  9. benchmark(lambda: _compile_page(evaluated_page, None))
  10. def test_compile_stateful(evaluated_page: Component, benchmark: BenchmarkFixture):
  11. import_templates()
  12. benchmark(lambda: _compile_stateful_components([evaluated_page]))
  13. def test_get_all_imports(evaluated_page: Component, benchmark: BenchmarkFixture):
  14. benchmark(lambda: evaluated_page._get_all_imports())