-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathprocess_dumps.py
70 lines (56 loc) · 1.9 KB
/
process_dumps.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
import collections
import json
import glob
import os
# Cd into dumps
os.chdir('dumps')
for suite in ['search', 'insertion']:
# A dict to hold data
DATA = collections.defaultdict(list)
for file_name in glob.glob("*-%s.json" % suite):
with open(file_name, 'r') as f:
datas = json.load(f)
for data in datas:
# Now, form a key to store the result
structure = data['structure']
size = data['size']
time = data['time']
comparisons = data['comparisons']
height = 0
if structure == 'skip_list':
height = data['height']
key = (structure, size)
# Results
r = {
'size': size,
'time': time,
'comparisons': comparisons,
'height': height
}
# Store result by key
DATA[key].append(r)
# To store the final results
RESULT = {}
# Process results
for experiment in DATA:
results = DATA[experiment]
# Get the data
comparisons = map(lambda d: d['comparisons'], results)
times = map(lambda d: d['time'], results)
heights = map(lambda d: d['height'], results)
# Get means
mean_comparisons = sum(comparisons) / float(len(comparisons))
mean_times = sum(times) / float(len(times))
mean_heights = sum(heights) / float(len(heights))
# Final result
r = {
'average_time': mean_times,
'average_comparisons': mean_comparisons,
'average_height': mean_heights,
'experiments': len(results)
}
# Store
RESULT[experiment] = r
print("Results for %s" % suite)
for experiment in RESULT:
print(experiment, RESULT[experiment])