diskDelay.prl
3.13 KB
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
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
#!/usr/local/bin/perl5
#
# Copyright (C) 1996-1998 by the Board of Trustees
# of Leland Stanford Junior University.
#
# This file is part of the SimOS distribution.
# See LICENSE file for terms of the license.
#
#
# Use the output from the disk device to measure the delays
# experienced by the disks.
#
# $Author: blythe $
# $Date: 2002/05/29 01:09:09 $
$inputFile = shift;
if (!defined( $inputFile)) {
$inputFile = "cpu.log";
}
open(LOG,$inputFile);
# Initialization
for ($i=0; $i<16; $i++) {
$savedOp[$disk] = 0;
$savedStart[$disk] = 0;
$savedSize[$disk] = 0;
$maxDiff[$disk] = 0;
$minDiff[$disk] = 10000000000;
$totalDiff[$disk] = 0;
}
$maxDisk = 0;
#$disklabel = 0;
$disk = 0;
while (<LOG>) {
($log,$time,$event,$cpu,$proc,$disklabel,$disk,$op,$sizelabel,$size) =
split;
if (defined($log) ) {
if ($log eq "CONFIG") {
if ($time eq "CpuClock") {
$clockRate = $event;
}
}
if ($log eq "LOG" ) {
if ($event eq "DISK-req" ) {
$savedOp[$disk] = $op;
$savedStart[$disk] = $time;
$savedSize[$disk] = $size;
if ($disk > $maxDisk) {
$maxDisk = $disk;
}
}
if ($event eq "DISK-ack" ) {
if ($savedStart[$disk] != 0 ) {
$diff = $time-$savedStart[$disk];
$allDiffs[$disk][$entries[$disk]] = $diff;
$entries[$disk]++;
if ($minDiff[$disk] > $diff ) {
$minDiff[$disk] = $diff;
}
if ($diff > $maxDiff[$disk]) {
$maxDiff[$disk] = $diff;
}
$totalDiff[$disk] += $diff;
$savedStart[$disk] = 0;
} else {
print "No start for disk $disk\n";
print $_;
}
}
}
}
}
$unit = $clockRate * 1000;
for ($disk=0; $disk <= $maxDisk; $disk++) {
printf("\nDisk %d\n", $disk);
printf("=======\n");
if ($entries[$disk]) {
$avgDiff = $totalDiff[$disk] * 1.0 / $entries[$disk];
printf("Requests=%d: Min = %3.1f Max = %3.1f Avg = %.2f [ms]\n",
$entries[$disk], $minDiff[$disk]/$unit,
$maxDiff[$disk]/$unit, $avgDiff/$unit);
$maxHisto = 0;
for ($i=0; $i < $entries[$disk]; $i++) {
$j = int($allDiffs[$disk][$i]*1.0/$unit);
$histogram[$disk][$j]++;
if ($j > $maxBucket[$disk]) {
$maxBucket[$disk] = $j;
}
}
for ($bucket=0; $bucket<=$maxBucket[$disk]; $bucket++) {
if (defined($histogram[$disk][$bucket]) ) {
printf("%d-%d ms:\t %5.2f %%\n", $bucket, $bucket+1,
100.0 * $histogram[$disk][$bucket]/$entries[$disk]);
} else {
printf("%d-%d ms:\t %5.2f\n", $bucket, $bucket+1, 0.0);
}
}
} else {
print "NO REQUESTS\n";
}
}