forked from TyGuS/hoogle_plus
-
Notifications
You must be signed in to change notification settings - Fork 0
/
results.py
119 lines (99 loc) · 4.02 KB
/
results.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
# generates a latex table with the results of the benchmarks
# expects the results to be in the bench-logs-extension
import time
exercises = [ "firstRight", "firstKey", "flatten", "repl-funcs", "containsEdge",
"multiApp", "appendN", "pipe", "intToBS", "cartProduct", "applyNtimes",
"firstMatch", "mbElem", "mapEither", "hoogle01", "zipWithResult", "splitStr",
"lookup", "fromFirstMaybes", "map", "maybe", "rights", "mbAppFirst",
"mergeEither", "test", "multiAppPair", "splitAtFirst", "2partApp", "areEq",
"eitherTriple", "mapMaybes", "head-rest", "appBoth", "applyPair",
"resolveEither", "head-tail", "indexesOf", "app3", "both", "takeNdropM",
"firstMaybe", "mbToEither", "pred-match", "singleList",
"mapAdd", "mapSquare", "appendConst", "filterDiff", "getFirstOnes",
"removeFirstOnes", "listIntersect", "indexConst", "allGreaterThan",
"dropConst", "filterGreaterThan", "filterPairs", "filterEq",
"replicateConst", "addElemsTwoLists", "sumSquares", "removeMax", "nandPair",
"allEqBool", "mapReverse", "allJust", "andListPairs", "sumPairEntries",
"filterPairsTyClass", "mapAddFloat", "mapAddLarge"]
dir1 = "hoogle_plus_ext/logs"
dir2 = "hoogle_plus_orig/logs"
dir3 = "hoogle_plus_examp/logs"
print("\\documentclass{article}")
print("\\begin{document}")
print("\\begin{table}")
print("\\centering")
print("\\caption{Results of the first set of benchmarks (collected ", time.asctime() ,"). Table 3 in the paper.}", sep='')
print("\\begin{tabular}{rl||rr||rr}")
print("\\hline ")
print(" & & \\multicolumn{2}{c||}{\\textsc{Hoogle+}} & \\multicolumn{2}{c}{Our Extension} \\\\")
print("\\# & Benchmark & Time (s) & Sols. & Time (s) & Sols. \\\\ \\hline")
ind = 0
for n in exercises:
ind +=1
try:
logfileE = open(dir1 + "/" + n + ".log")
logfileO = open(dir2 + "/" + n + ".log")
except:
continue
linesE = logfileE.readlines()
linesO = logfileO.readlines()
solsE, solsO = len(linesE) // 2, len(linesO) // 2
timeE = timeO = '-'
if len(linesO) > 1:
timesO = linesO[1].split()
if len(timesO) == 1:
timeO = round(float(timesO[0]), 2)
else:
raise ValueError('Expected one real number')
if len(linesE) > 1:
timesE = linesE[1].split()
if len(timesE) == 2:
timeE = round(float(timesE[1]), 2)
else:
raise ValueError('Expected two real numbers')
print(ind, "&", n, "&", timeO, "&", solsO, "&", timeE, "&", solsE, "\\\\")
logfileO.close()
logfileE.close()
print("\\hline ")
print("\\end{tabular}")
print("\end{table}")
print("\\begin{table}")
print("\\centering")
print("\\caption{Results of the second set of benchmarks (collected ", time.asctime() ,"). Table 4 in the paper.}", sep='')
print("\\begin{tabular}{rl||rr||rrr}")
print("\\hline ")
print(" & & \\multicolumn{2}{c||}{\\textsc{Hoogle+}} & \\multicolumn{3}{c}{Our Extension} \\\\")
print("\\# & Benchmark & Time (s) & Sols. & Time (s) & Unify & Sols. \\\\ \\hline")
print("\\hline ")
ind = 0
for n in exercises:
ind +=1
try:
logfileE = open(dir1 + "/" + n + ".log")
logfileO = open(dir3 + "/" + n + ".log")
except:
continue
linesE = logfileE.readlines()
linesO = logfileO.readlines()
solsE, solsO = len(linesE) // 2, len(linesO) // 2
matchE = timeE = timeO = '-'
if len(linesO) > 1:
timesO = linesO[1].split()
if len(timesO) == 1:
timeO = round(float(timesO[0]), 2)
else:
raise ValueError('Expected two real numbers')
if len(linesE) > 1:
timesE = linesE[1].split()
if len(timesE) == 2:
timeE = round(float(timesE[1]), 2)
matchE = round(float(timesE[0]), 2)
else:
raise ValueError('Expected two real numbers')
print(ind, "&", n, "&", timeO, "&", solsO, "&", timeE, "&", matchE, "&", solsE, "\\\\")
logfileO.close()
logfileE.close()
print("\\hline ")
print("\\end{tabular}")
print("\\end{table}")
print("\\end{document}")