forked from chipsalliance/rocket-chip
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtracestats.py
executable file
·76 lines (65 loc) · 2.09 KB
/
tracestats.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
#!/usr/bin/env python
# This file was originally written by Matthew Naylor, University of
# Cambridge.
#
# This software was partly developed by the University of Cambridge
# Computer Laboratory under DARPA/AFRL contract FA8750-10-C-0237
# ("CTSRD"), as part of the DARPA CRASH research programme.
#
# This software was partly developed by the University of Cambridge
# Computer Laboratory under DARPA/AFRL contract FA8750-11-C-0249
# ("MRC2"), as part of the DARPA MRC research programme.
#
# This software was partly developed by the University of Cambridge
# Computer Laboratory as part of the Rigorous Engineering of
# Mainstream Systems (REMS) project, funded by EPSRC grant
# EP/K008528/1.
# -------
# Outline
# -------
# Usage:
#
# tracegen-stats.py STATS-FILE
#
# This script produces some statistics about the traces generated
# using tracegen.py.
import sys
import subprocess
import re
def main():
if len(sys.argv) != 2:
sys.stderr.write("Usage: tracegen-stats.py STATS-FILE\n")
sys.exit(-1)
f = open(sys.argv[1], 'r')
if f == None:
sys.stderr.write("File not found: " + sys.argv[1] + "\n")
sys.exit(-1)
lrscSuccessSum = 0.0
lrscSuccessCount = 0
loadExtRateSum = 0.0
loadExtRateCount = 0
for line in f:
if line[0:18] == "LRSC_Success_Rate=":
val = float(line[18:-1])
lrscSuccessSum = lrscSuccessSum + val
lrscSuccessCount = lrscSuccessCount + 1
if line[0:19] == "Load_External_Rate=":
val = float(line[19:-1])
loadExtRateSum = loadExtRateSum + val
loadExtRateCount = loadExtRateCount + 1
if lrscSuccessCount > 0:
lrscSuccessAvg = lrscSuccessSum / float(lrscSuccessCount)
lrscSuccessRate = str(int(100.0*lrscSuccessAvg)) + "%"
print "LR/SC success rate:", lrscSuccessRate
else:
print "LR/SC success rate: none performed"
if loadExtRateCount > 0:
loadExtRateAvg = loadExtRateSum / float(loadExtRateCount)
loadExtRate = str(int(100.0*loadExtRateAvg)) + "%"
print "Load-external rate:", loadExtRate
else:
print "Load-external rate: none performed"
try:
main()
except KeyboardInterrupt:
sys.exit(-1)