source: proto/RE/performance/datgen.py @ 3474

Last change on this file since 3474 was 3474, checked in by bhull, 6 years ago

Rough chart input generator.

File size: 1.4 KB
Line 
1from subprocess import call, Popen
2from collections import *
3import csv
4import StringIO
5import os.path
6import sys
7import shutil
8
9InputRow = namedtuple('InputRow', ['file','expression','program','stat','value','value2','value3','value4'])
10
11
12
13
14Datfile = namedtuple('Datfile', ['file','program','stat','rows'])
15Datrow = namedtuple('Datrow', ['number','fileexpressions'])
16FileExpression=namedtuple('FileExpression', ['file','expression'])
17
18datfiles = []
19datfiles.append(Datfile('dat1.dat','bitstreams','cycles:u',(Datrow('0',(FileExpression('mark_twain','Twain'),)),Datrow('1',(FileExpression('mark_twain','Twain$'),)),Datrow('2',(FileExpression('mark_twain','Huck_or_Finn_'),)),Datrow('3',(FileExpression('mark_twain','a----b'),)),Datrow('4',(FileExpression('mark_twain','Tom_or_Huck'),)),)))
20
21
22incsv = []
23for row in map(InputRow._make, csv.reader(open("output.csv", "rb"))):
24    incsv.append(row)
25
26for datfile in datfiles:
27        f = open(datfile.file, 'w')
28        for datrow in datfile.rows:
29                value=0
30                valuecount=0
31                for row in incsv:
32                        for fileexpression in datrow.fileexpressions:
33                                if row.expression==fileexpression.expression and row.file == fileexpression.file and row.program==datfile.program and row.stat==datfile.stat:
34                                        value=value+int(row.value)
35                                        valuecount=valuecount+1
36                if valuecount>0:
37                        value = value/valuecount
38                f.write(datrow.number)
39                f.write(' ')
40                f.write(str(value))
41                f.write('\n')
42        f.close()
Note: See TracBrowser for help on using the repository browser.