-
Notifications
You must be signed in to change notification settings - Fork 0
/
__main__.py
56 lines (48 loc) · 1.77 KB
/
__main__.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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
from template.db import Database
from template.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, 1000):
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 = [
[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), None],
[None, None, None, None, randrange(0, 100)],
]
update_time_0 = process_time()
for i in range(0, 1000):
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)
# Measuring Select Performance
select_time_0 = process_time()
for i in range(0, 1000):
query.select(choice(keys),0 , [1, 1, 1, 1, 1])
select_time_1 = process_time()
print("Selecting 10k records took: \t\t\t", select_time_1 - select_time_0)
# Measuring Aggregate Performance
agg_time_0 = process_time()
for i in range(0, 1000, 100):
start_value = 906659671 + i
end_value = start_value + 100
result = query.sum(start_value, end_value - 1, randrange(0, 5))
agg_time_1 = process_time()
print("Aggregate 10k of 100 record batch took:\t", agg_time_1 - agg_time_0)
# Measuring Delete Performance
delete_time_0 = process_time()
for i in range(0, 1000):
query.delete(906659671 + i)
delete_time_1 = process_time()
print("Deleting 10k records took: \t\t\t", delete_time_1 - delete_time_0)