瀏覽代碼

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()

部分文件因文件數量過多而無法顯示