File tree Expand file tree Collapse file tree 2 files changed +22
-4
lines changed
Expand file tree Collapse file tree 2 files changed +22
-4
lines changed Original file line number Diff line number Diff line change 1+ from __future__ import annotations
2+
13import asyncio
24from decimal import Decimal
35import random
@@ -17,13 +19,13 @@ def setup_database():
1719
1820@pytest .fixture (scope = "module" , autouse = True )
1921def skip_if_codspeed_not_enabled (request ):
20- if not request .config .getoption ("--codspeed" ):
21- pytest .skip ("codspeed tests are disabled " )
22+ if not request .config .getoption ("--codspeed" , default = None ):
23+ pytest .skip ("codspeed is not enabled " )
2224
2325
2426@pytest .fixture
2527def few_fields_benchmark_dataset () -> list [BenchmarkFewFields ]:
26- async def _create ():
28+ async def _create () -> list [ BenchmarkFewFields ] :
2729 res = []
2830 for _ in range (100 ):
2931 res .append (await BenchmarkFewFields .create (level = random .randint (0 , 100 ), text = "test" ))
@@ -34,7 +36,7 @@ async def _create():
3436
3537@pytest .fixture
3638def many_fields_benchmark_dataset () -> list [BenchmarkManyFields ]:
37- async def _create ():
39+ async def _create () -> list [ BenchmarkManyFields ] :
3840 res = []
3941 for _ in range (100 ):
4042 res .append (
Original file line number Diff line number Diff line change 1+ import asyncio
2+ import random
3+
4+ from tests .testmodels import BenchmarkFewFields
5+
6+
7+ def test_filter_few_fields (benchmark , few_fields_benchmark_dataset ):
8+ loop = asyncio .get_event_loop ()
9+ levels = list (set ([o .level for o in few_fields_benchmark_dataset ]))
10+
11+ @benchmark
12+ def bench ():
13+ async def _bench ():
14+ await BenchmarkFewFields .filter (level__in = random .sample (levels , 5 )).limit (5 )
15+
16+ loop .run_until_complete (_bench ())
You can’t perform that action at this time.
0 commit comments