-
-
Notifications
You must be signed in to change notification settings - Fork 400
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add more Codspeed benchmarks (#1834)
* Add test_filter_many_filters benchmark * Add bulk_create benchmarks
- Loading branch information
Showing
10 changed files
with
112 additions
and
85 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
import asyncio | ||
import random | ||
|
||
from tests.testmodels import BenchmarkFewFields, BenchmarkManyFields | ||
|
||
|
||
def test_bulk_create_few_fields(benchmark): | ||
loop = asyncio.get_event_loop() | ||
|
||
data = [ | ||
BenchmarkFewFields( | ||
level=random.choice([10, 20, 30, 40, 50]), text=f"Insert from C, item {i}" # nosec | ||
) | ||
for i in range(100) | ||
] | ||
|
||
@benchmark | ||
def bench(): | ||
async def _bench(): | ||
await BenchmarkFewFields.bulk_create(data) | ||
|
||
loop.run_until_complete(_bench()) | ||
|
||
|
||
def test_bulk_create_many_fields(benchmark, gen_many_fields_data): | ||
loop = asyncio.get_event_loop() | ||
|
||
data = [BenchmarkManyFields(**gen_many_fields_data()) for _ in range(100)] | ||
|
||
@benchmark | ||
def bench(): | ||
async def _bench(): | ||
await BenchmarkManyFields.bulk_create(data) | ||
|
||
loop.run_until_complete(_bench()) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters