-
Notifications
You must be signed in to change notification settings - Fork 1
/
__hundred_thousand_operations_comparison.py
166 lines (141 loc) · 5.46 KB
/
__hundred_thousand_operations_comparison.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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
from lstore.db import Database
from lstore.query import Query
from time import process_time
from random import choice, randrange
print("100K")
# 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, 100000):
query.insert(906659671 + i, 93, 0, 0, 0)
keys.append(906659671 + i)
insert_time_1 = process_time()
print("Inserting 100K 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, 100000):
query.update(choice(keys), *(choice(update_cols)))
update_time_1 = process_time()
print("Updating 100K records took: \t\t\t", update_time_1 - update_time_0)
# Measuring Select Performance
select_time_0 = process_time()
for i in range(0, 100000):
query.select(choice(keys),0 , [1, 1, 1, 1, 1])
select_time_1 = process_time()
print("Selecting 100K records took: \t\t\t", select_time_1 - select_time_0)
# Measuring Aggregate Performance
agg_time_0 = process_time()
for i in range(0, 100000, 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 100K 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, 100000):
query.delete(906659671 + i)
delete_time_1 = process_time()
print("Deleting 100K records took: \t\t\t", delete_time_1 - delete_time_0)
print("----------------------------------------------------------------------------------------")
print("150K")
# 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, 150000):
query.insert(906659671 + i, 93, 0, 0, 0)
keys.append(906659671 + i)
insert_time_1 = process_time()
print("Inserting 150K 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, 150000):
query.update(choice(keys), *(choice(update_cols)))
update_time_1 = process_time()
print("Updating 150K records took: \t\t\t", update_time_1 - update_time_0)
# Measuring Select Performance
select_time_0 = process_time()
for i in range(0, 150000):
query.select(choice(keys),0 , [1, 1, 1, 1, 1])
select_time_1 = process_time()
print("Selecting 150K records took: \t\t\t", select_time_1 - select_time_0)
# Measuring Aggregate Performance
agg_time_0 = process_time()
for i in range(0, 150000, 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 150K 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, 150000):
query.delete(906659671 + i)
delete_time_1 = process_time()
print("Deleting 150K records took: \t\t\t", delete_time_1 - delete_time_0)
print("----------------------------------------------------------------------------------------")
print("200K")
# 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, 200000):
query.insert(906659671 + i, 93, 0, 0, 0)
keys.append(906659671 + i)
insert_time_1 = process_time()
print("Inserting 200K 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, 200000):
query.update(choice(keys), *(choice(update_cols)))
update_time_1 = process_time()
print("Updating 200K records took: \t\t\t", update_time_1 - update_time_0)
# Measuring Select Performance
select_time_0 = process_time()
for i in range(0, 200000):
query.select(choice(keys),0 , [1, 1, 1, 1, 1])
select_time_1 = process_time()
print("Selecting 200K records took: \t\t\t", select_time_1 - select_time_0)
# Measuring Aggregate Performance
agg_time_0 = process_time()
for i in range(0, 200000, 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 200K 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, 200000):
query.delete(906659671 + i)
delete_time_1 = process_time()
print("Deleting 200K records took: \t\t\t", delete_time_1 - delete_time_0)