Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Latest commit

 

History

History
History
48 lines (38 loc) · 1.44 KB

File metadata and controls

48 lines (38 loc) · 1.44 KB
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
import random
import string
import pytest
from benchmarks.conftest import Author, Book, Publisher
pytestmark = pytest.mark.asyncio
@pytest.mark.parametrize("num_models", [250, 500, 1000])
async def test_initializing_models(aio_benchmark, num_models: int):
@aio_benchmark
async def initialize_models(num_models: int):
authors = [
Author(
name="".join(random.sample(string.ascii_letters, 5)),
score=int(random.random() * 100),
)
for i in range(0, num_models)
]
assert len(authors) == num_models
_ = initialize_models(num_models)
@pytest.mark.parametrize("num_models", [10, 20, 40])
async def test_initializing_models_with_related_models(aio_benchmark, num_models: int):
@aio_benchmark
async def initialize_models_with_related_models(
author: Author, publisher: Publisher, num_models: int
):
_ = [
Book(
author=author,
publisher=publisher,
title="".join(random.sample(string.ascii_letters, 5)),
year=random.randint(0, 2000),
)
for i in range(0, num_models)
]
author = await Author(name="Author", score=10).save()
publisher = await Publisher(name="Publisher", prestige=random.randint(0, 10)).save()
_ = initialize_models_with_related_models(
author=author, publisher=publisher, num_models=num_models
)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.