-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathresultify.py
56 lines (44 loc) · 1.79 KB
/
resultify.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
#resultify.py outputs results to csv
import csv
import json
import subprocess
with open('results.json') as datafile:
data = json.load(datafile)
resultfile = open('results.csv','wb')
resultwriter = csv.writer(resultfile,delimiter=' ')
resultwriter.writerow( ('FS_Size', 'Aged_Time', 'Clean_Time', 'Aged_Layout_Score', 'Clean_Layout_Score') )
for i in range(0,len(data)):
print('Processing test ' + str(i))
subprocess.call('blkparse -q -a issue -f "%S %n \n" -i trace' + str(i).zfill(6) + '.blktrace.0 > agedgrep.txt', cwd='traces', shell=True)
discontiguities = -1
totalblocks = 0
with open('traces/agedgrep.txt') as tracefile:
lastsector = -1
for line in tracefile:
splitline = line.split()
if splitline[0].isdigit():
sector = int(splitline[0])
length = int(splitline[1])
if lastsector != sector:
discontiguities = discontiguities + 1
lastsector = sector + length
totalblocks = totalblocks + length/8
aged_layout_score = str(float(1) - float(discontiguities)/float(totalblocks))
subprocess.call('blkparse -q -a issue -f "%S %n \n" -i cleantrace' + str(i).zfill(6) + '.blktrace.0 > cleangrep.txt', cwd='traces', shell=True)
discontiguities = -1
totalblocks = 0
with open('traces/cleangrep.txt') as tracefile:
lastsector = -1
for line in tracefile:
splitline = line.split()
if splitline[0].isdigit():
sector = int(splitline[0])
length = int(splitline[1])
if lastsector != sector:
discontiguities = discontiguities + 1
lastsector = sector + length
totalblocks = totalblocks + length/8
clean_layout_score = str(float(1) - float(discontiguities)/float(totalblocks))
resultrow = (data[i] + [aged_layout_score, clean_layout_score])
resultwriter.writerow(resultrow)
subprocess.call('sudo rm -f *.txt', cwd='traces', shell=True)