Преглед на файлове

add stateful benchmarks (#4764)

* add stateful benchmarks

* make stateful stuff more complex

* unpack tuple in itertag

* fix comment
Thomas Brandého преди 3 месеца
родител
ревизия
a31301cb4f
променени са 4 файла, в които са добавени 77 реда и са изтрити 7 реда
  1. 4 0
      reflex/components/tags/iter_tag.py
  2. 2 2
      tests/benchmarks/conftest.py
  3. 69 0
      tests/benchmarks/fixtures.py
  4. 2 5
      tests/benchmarks/test_evaluate.py

+ 4 - 0
reflex/components/tags/iter_tag.py

@@ -134,6 +134,10 @@ class IterTag(Tag):
         if isinstance(component, (Foreach, Cond)):
             component = Fragment.create(component)
 
+        # If the component is a tuple, unpack and wrap it in a fragment.
+        if isinstance(component, tuple):
+            component = Fragment.create(*component)
+
         # Set the component key.
         if component.key is None:
             component.key = index

+ 2 - 2
tests/benchmarks/conftest.py

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

Файловите разлики са ограничени, защото са твърде много
+ 69 - 0
tests/benchmarks/fixtures.py


+ 2 - 5
tests/benchmarks/test_evaluate.py

@@ -1,9 +1,6 @@
 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()
+def test_evaluate_page(unevaluated_page):
+    unevaluated_page()

Някои файлове не бяха показани, защото твърде много файлове са промени