import templates beforehands

This commit is contained in:
Khaleel Al-Adhami 2025-02-12 14:24:14 -08:00
parent 0ae79b1b18
commit eb016119a0

View File

@ -4,11 +4,20 @@ 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]))