-
Notifications
You must be signed in to change notification settings - Fork 0
/
measure.py
executable file
·95 lines (75 loc) · 2.02 KB
/
measure.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
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
path = "/tmp/fs-part4.log"
with open(path,'r') as f:
f.readline();
f.readline();
opr1 = ''
while opr1 != 'read' :
first_time = 0
line1 = f.readline()
if line1 == "": break
words = line1.split()
opr1 = words[0]
blk_num1 = int(words[1])
len1 = int(words[2])
total_read = 1;
sequential_read = 1;
#print opr1, blk_num1, len1
first_time = 1;
opr2 = '';
while True:
while opr2 != 'read':
line2 = f.readline()
if line2 == "": break
words = line2.split()
opr2 = words[0]
blk_num2 = int(words[1])
len2 = int(words[2])
if line2 == "":break
total_read = total_read + 1;
if (blk_num1 + len1) != blk_num2 :
sequential_read = sequential_read + 1;
blk_num1 = blk_num2;
len1 = len2;
opr2 = '';
print "=======================================================";
print "the total number of reads is %d" % total_read;
print "the number of sequential reads is %d" % sequential_read;
print "=======================================================";
f.close();
with open(path,'r') as f:
f.readline();
f.readline();
opr1 = ''
while opr1 != 'write' :
first_time = 0
line1 = f.readline()
if line1 == "": break
words = line1.split()
opr1 = words[0]
blk_num1 = int(words[1])
len1 = int(words[2])
total_write = 1;
sequential_write = 1;
#print opr1, blk_num1, len1
first_time = 1;
opr2 = '';
while True:
while opr2 != 'write':
line2 = f.readline()
if line2 == "": break
words = line2.split()
opr2 = words[0]
blk_num2 = int(words[1])
len2 = int(words[2])
if line2 == "":break
total_write = total_write + 1;
if (blk_num1 + len1) != blk_num2 :
sequential_write = sequential_write + 1;
blk_num1 = blk_num2;
len1 = len2;
opr2 = '';
print "=======================================================";
print "the total number of writes is %d" % total_write;
print "the number of sequential writes is %d" % sequential_write;
print "=======================================================";
f.close();