forked from gupta-suyash/cs451-551-fall24
-
Notifications
You must be signed in to change notification settings - Fork 0
/
__main__.py
67 lines (58 loc) · 2.13 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
57
58
59
60
61
62
63
64
65
66
67
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)
# Measuring Select Performance
select_time_0 = process_time()
for i in range(0, 10000):
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, 10000, 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\t\t", agg_time_1 - agg_time_0)
"""
# Measuring range query on values
aggregate_on_value_0 = process_time()
for i in range(0, 10000):
begin_val = 30
end_val = 60
result = query.count(begin_val, end_val, randrange(1, 5))
aggregate_on_value_1 = process_time()
print("Aggregate on Value 10k records with value between 30 and 60 took: \t\t\t", aggregate_on_value_1 - aggregate_on_value_0)
"""
# Measuring Delete Performance
delete_time_0 = process_time()
for i in range(0, 10000):
query.delete(906659671 + i)
delete_time_1 = process_time()
print("Deleting 10k records took: \t\t\t", delete_time_1 - delete_time_0)