-
Notifications
You must be signed in to change notification settings - Fork 2
/
analyze.py
56 lines (43 loc) · 977 Bytes
/
analyze.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
import os
import string
fp = open("csv", "r")
class ASU:
def __init__(self, asu):
self.asu = asu
self.reads = {}
self.writes = {}
def io(self, rw, offset):
if rw == 0:
self.read(offset)
else:
self.write(offset)
def read(self, offset):
try:
self.reads[offset] += 1
except:
self.reads[offset] = 1
def write(self, offset):
try:
self.writes[offset] += 1
except:
self.writes[offset] = 1
def tocsv(self):
rcsv = open("asu%d_r.csv" % self.asu, "w")
wcsv = open("asu%d_w.csv" % self.asu, "w")
for r in self.reads:
rcsv.write("%s,%d\n" % (r, self.reads[r]))
for w in self.writes:
wcsv.write("%s,%d\n" % (w, self.writes[w]))
asus = [ ASU(1), ASU(2), ASU(3)]
for line in fp.readlines():
csv = line.split(',')
rw = int(csv[1].strip())
asu = int(csv[2].strip())
len = int(csv[3].strip())
offset = int(csv[4].strip())
while len > 0:
asus[asu-1].io(rw, offset)
offset += 1
len -= 1
for asu in asus:
asu.tocsv()