Skip to content

Instantly share code, notes, and snippets.

@dare0021
Created May 18, 2017 08:27
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dare0021/59c379c90cec0ecc1a0aa7e87c722707 to your computer and use it in GitHub Desktop.
Save dare0021/59c379c90cec0ecc1a0aa7e87c722707 to your computer and use it in GitHub Desktop.
import pyperclip as clipboard
# path of file to open
openFile = "stats.txt"
# row will be populated in this order
L2Size = 2
L3Size = 4
TestSet = "gcc"
keysToLookFor = ['sim_seconds',
'host_inst_rate',
'system.switch_cpus.ipc_total',
'host_op_rate',
'system.cpu.dcache.overall_avg_miss_latency::total',
'system.cpu.dcache.overall_miss_rate::total',
'system.l2.overall_miss_latency::total',
'system.l2.overall_miss_rate::total',
'system.l3.overall_miss_latency::total',
'system.l3.overall_miss_rate::total']
keysFound = 0
retval = "" + str(L2Size) + '\t' + str(L3Size) + "\t" + TestSet
d = dict()
def parseItem (sLine):
global d, keysFound
sarr = sLine.split()
if (sarr[0] in keysToLookFor):
d[sarr[0]] = sarr[1]
keysFound += 1
f = open(openFile, 'r')
# first line is always empty
f.readline()
if (f.readline() != "---------- Begin Simulation Statistics ----------\n"):
print "check input file path"
import sys
sys.exit()
s = f.readline()
while (len(s) > 1 and keysFound < len(keysToLookFor)):
parseItem(s)
s = f.readline()
f.close()
for key in keysToLookFor:
if key in d:
retval += "\t" + str(d[key])
else:
retval += "\tN/A"
clipboard.copy(retval)
print retval
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment