-
Notifications
You must be signed in to change notification settings - Fork 11
/
scene_random_writes.py
34 lines (27 loc) · 987 Bytes
/
scene_random_writes.py
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
import random
from pyinstrument.profiler import Profiler
import dictdatabase as DDB
user_count = 100_000
# all_users = {}
# for i in range(user_count):
# user = {
# "id": str(i),
# "pref": "".join(random.choices("abcdefghijklmnopqrstuvwxyz0123456789", k=8)),
# "name": "".join(random.choices("abcdefghijklmnopqrstuvwxyz", k=5)),
# "surname": "".join(random.choices("abcdefghijklmnopqrstuvwxyz", k=20)),
# "description": "".join(random.choices("abcdefghij\"klmnopqrst😁uvwxyz\\ ", k=5000)),
# "age": random.randint(0, 100),
# }
# all_users[str(i)] = user
# DDB.at("users").create(all_users, force_overwrite=True)
print("Users created")
p = Profiler(interval=0.0001)
p.start()
for it in range(500):
print(it)
user_id = str(random.randint(user_count - 100, user_count - 1))
with DDB.at("users", key=user_id).session() as (session, user):
user["age"] += 1
session.write()
p.stop()
p.open_in_browser(timeline=False)