-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinsert_test.py
33 lines (28 loc) · 1000 Bytes
/
insert_test.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
from lstore.db import Database
from lstore.query import Query
from time import process_time
from random import choice, randrange
# Student Id and 4 grades
db = Database()
grades_table = db.create_table('Grades', 5, 0)
query = Query(grades_table)
keys = []
insert_time_0 = process_time()
for i in range(0, 10000):
query.insert(906659671 + i, 93, 0, 0, 0)
keys.append(906659671 + i)
insert_time_1 = process_time()
print("Inserting 10k records took: \t\t\t", insert_time_1 - insert_time_0)
# Measuring update Performance
update_cols = [
[None, None, None, None, None],
[None, randrange(0, 100), None, None, None],
[None, None, randrange(0, 100), None, None],
[None, None, None, randrange(0, 100), None],
[None, None, None, None, randrange(0, 100)],
]
update_time_0 = process_time()
for i in range(0, 10000):
query.update(choice(keys), *(choice(update_cols)))
update_time_1 = process_time()
print("Updating 10k records took: \t\t\t", update_time_1 - update_time_0)