-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathperftest.py
More file actions
64 lines (51 loc) · 1.94 KB
/
perftest.py
File metadata and controls
64 lines (51 loc) · 1.94 KB
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
import snowflake.connector
import time
satori_con = snowflake.connector.connect(
user='<YOUR USERNAME>',
password='<YOUR PASSWORD>',
account='<YOUR SNOWFLAKE ACCOUNT>',
host='<YOUR SATORI HOSTNAME>',
database='snowflake_sample_data',
schema='tpch_sf1',
warehouse='<YOUR VIRTUAL DATA WAREHOUSE>'
)
direct_con = snowflake.connector.connect(
user='<YOUR USERNAME>',
password='<YOUR PASSWORD>',
account='<YOUR SNOWFLAKE ACCOUNT>',
database='snowflake_sample_data',
schema='tpch_sf1',
warehouse='<YOUR VIRTUAL DATA WAREHOUSE>'
)
NUM_OF_SAMPLES = 100
def benchmark(with_satori: bool):
if with_satori:
print("Benchmarking with Satori!")
else:
print("Benchmarking without Satori")
filename = "results_with_satori.txt" if with_satori else "results_without_satori.txt"
with open(filename, 'w') as result_file:
with open('tpch.sql') as f:
all_queries = f.read()
results = "Test\tTime\n"
for i in range(0, NUM_OF_SAMPLES):
# Running the benchmark for each query in the queries file
for query in all_queries.split(';'):
label = query.split("-- ")[1].split('\n')[0]
query = query.rstrip()
start_ts = time.time()
cs = satori_con.cursor() if with_satori else direct_con.cursor()
cs.execute(query)
rows = cs.fetchall()
for _row in rows:
continue
end_ts = time.time()
delta = end_ts-start_ts
# Results are tab-delimited for easy pasting to a spreadsheet
results += "{0:s}\t{1:3.5f}\n".format(label, delta)
result_file.write(results)
if __name__ == '__main__':
# Running benchmarks without Satori
benchmark(False)
# Running benchmarks with Satori
benchmark(True)