]> matita.cs.unibo.it Git - helm.git/blob - matita/bench_summary.py
matita now works reasonably well,
[helm.git] / matita / bench_summary.py
1 #!/usr/bin/python
2 import sys
3
4 stats = {}
5 stats['total'] = []
6 stats['precise'] = []
7 stats['imprecise'] = []
8 stats['false-positives'] = []
9 stats['undetected'] = []
10
11 for line in open(sys.argv[1]):
12     line = line.rstrip()
13     if line[0] == '#':
14         continue
15     cols = line.split('|')
16     name = cols[0]
17     if cols[1] != 'KO':
18         print "Warning: outcome of %s is %s, skipping it" % (name, cols[1])
19         continue
20     expected_error = cols[2]
21     real_errors = cols[3].split(',')
22     spurious_errors = cols[4].split(',')
23
24     stats['total'].append((name,real_errors))
25     if set([expected_error]) == set(real_errors):
26         if expected_error in spurious_errors:
27             stats['false-positives'].append((name,real_errors))
28         else:
29             stats['precise'].append((name,real_errors))
30     elif expected_error in real_errors:
31         if expected_error in spurious_errors:
32             stats['false-positives'].append((name,real_errors))
33         else:
34             stats['imprecise'].append((name,real_errors))
35     else:
36         if expected_error in spurious_errors:
37             stats['false-positives'].append((name,real_errors))
38         else:
39             stats['undetected'].append((name,real_errors))
40
41 for field in ['undetected', 'imprecise', 'false-positives']:
42     print "===================="
43     print "%s:" % field
44     for name,_ in stats[field]:
45         print "  %s" % name
46
47 def average(l):
48     if not(len(l)):
49         return "N/A"
50     else:
51         return "%6.1f" % (reduce(lambda acc,x: acc+x,l,0)/float(len(l)))
52
53 def mymax(l):
54     if not(len(l)):
55         return 0
56     else:
57         return max(l)
58
59 def format_stat(field):
60     global stats
61     lista = stats[field]
62     errors = map(lambda x: len(x[1]),lista)
63     locations = map(lambda x: len(set(x[1])),lista)
64     return r'%-15s & %6d & %6s & %6d & %6s & %6d & %6.1f\%% \\' % \
65             (field, len(lista), average(locations),mymax(locations),
66             average(errors),mymax(errors),float(len(lista)) /
67             len(stats['total']) * 100)
68
69 print "\n"
70 print format_stat('precise')
71 print format_stat('imprecise')
72 print format_stat('false-positives')
73 print format_stat('undetected')
74 print r'\hline'
75 print format_stat('total')