-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathexperiments.py
134 lines (108 loc) · 4.84 KB
/
experiments.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
import json
import os
import time
import csv
from subprocess import *
def jarWrapper(package, args):
last_line = ''
with Popen(['java', '-Xmx10G', '-cp',
os.path.dirname(os.path.abspath(__file__)) + '/target/queries-1.0-SNAPSHOT.jar',
package] + list(args), stdout=PIPE, bufsize=1, universal_newlines=True) as p:
for line in p.stdout:
last_line = line
return last_line
package_az_fi_apprx = 'de.lindener.analysis.amazon.AZFrequentItemsApproximate'
package_az_fi_exact = 'de.lindener.analysis.amazon.AZFrequentItemsExact'
package_az_hll_apprx = 'de.lindener.analysis.amazon.AZHllApproximate'
package_wt_fi_apprx = 'de.lindener.analysis.wikitrace.WTFrequentItemsApproximate'
package_il_fi_apprx = 'de.lindener.analysis.impressions.ILFrequentItemsApproximate'
package_il_fi_exact = 'de.lindener.analysis.impressions.ILFrequentItemsExact'
map_sizes = [16384, 32768, 65536, 131072]
def runAZFIApprx(emit_min=1000, bound=0, map_size=128):
args = ['--emit-min', str(emit_min), '--bound', str(bound), '--map-size', str(map_size)]
start = time.time()
result = jarWrapper(package_az_fi_apprx, args)
end = time.time()
result = json.loads(result)
runtime = end - start
return {'mapSize': map_size, 'runtime': runtime, 'resultPath': result['resultPath']}
def runAZFIExact(emit_min=1000, bound=0, map_size=128):
args = ['--emit-min', str(emit_min), '--bound', str(bound), '--map-size', str(map_size)]
start = time.time()
result = jarWrapper(package_az_fi_exact, args)
end = time.time()
result = json.loads(result)
runtime = end - start
return {'mapSize': map_size, 'runtime': runtime, 'resultPath': result['resultPath']}
def runWTFIApprx(emit_min=1000, bound=0, map_size=128):
args = ['--emit-min', str(emit_min), '--bound', str(bound), '--map-size', str(map_size)]
start = time.time()
result = jarWrapper(package_wt_fi_apprx, args)
end = time.time()
result = json.loads(result)
runtime = end - start
return {'mapSize': map_size, 'runtime': runtime, 'resultPath': result['resultPath']}
def runILFIExact(emit_min=1000, bound=0, map_size=128):
args = ['--emit-min', str(emit_min), '--bound', str(bound), '--map-size', str(map_size)]
start = time.time()
result = jarWrapper(package_il_fi_exact, args)
end = time.time()
result = json.loads(result)
runtime = end - start
return {'mapSize': map_size, 'runtime': runtime, 'resultPath': result['resultPath']}
def runILFIApprx(emit_min=1000, bound=10000000, map_size=128):
args = ['--emit-min', str(emit_min), '--bound', str(bound), '--map-size', str(map_size)]
start = time.time()
result = jarWrapper(package_il_fi_apprx, args)
end = time.time()
result = json.loads(result)
runtime = end - start
return {'mapSize': map_size, 'runtime': runtime, 'resultPath': result['resultPath']}
def runHLLApprx(emit_min=1000):
args = ['--emit-min', str(emit_min)]
start = time.time()
result = jarWrapper(package_az_hll_apprx, args)
end = time.time()
result = json.loads(result)
runtime = end - start
return {'runtime': runtime, 'resultPath': result['resultPath']}
def runHLLTests():
fieldnames = ['runtime', 'resultPath']
with open('HLL_APPRX.csv', 'w', newline='') as csvfile:
writer = csv.DictWriter(csvfile, fieldnames=fieldnames)
writer.writeheader()
result = runHLLApprx(emit_min=10000)
writer.writerow(result)
def runFITests():
fieldnames = ['mapSize', 'runtime', 'resultPath']
with open('WTFI_APPRX.csv', 'w', newline='') as csvfile:
writer = csv.DictWriter(csvfile, fieldnames=fieldnames)
writer.writeheader()
for mapSize in map_sizes:
result = runWTFIApprx(emit_min=10000, map_size=mapSize)
writer.writerow(result)
# with open('AZFI_APPRX.csv', 'w', newline='') as csvfile:
# writer = csv.DictWriter(csvfile, fieldnames=fieldnames)
# writer.writeheader()
# for mapSize in map_sizes:
# result = runAZFIApprx(map_size=mapSize)
# writer.writerow(result)
# with open('ILFI_APPRX.csv', 'w', newline='') as csvfile:
# writer = csv.DictWriter(csvfile, fieldnames=fieldnames)
# writer.writeheader()
# for mapSize in map_sizes:
# result = runILFIApprx(map_size=mapSize)
# writer.writerow(result)
# with open('AZFI_EXACT.csv', 'w', newline='') as csvfile:
# writer = csv.DictWriter(csvfile, fieldnames=fieldnames)
# writer.writeheader()
# result = runAZFIExact()
# writer.writerow(result)
#
# with open('ILFI_EXACT.csv', 'w', newline='') as csvfile:
# writer = csv.DictWriter(csvfile, fieldnames=fieldnames)
# writer.writeheader()
# result = runILFIExact()
# writer.writerow(result)
runFITests()
# runHLLTests()