mt-time-profile.prl
6.54 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
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
#!/usr/local/bin/perl5 -w
#
# 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.
#
# This script generates a profile of a workload over time.
# used in doProfile script to generate profile.ps
# grouping value (default is 1)
$old = 0; #set old=1 to get the new value.
# Graph Variables
$WIDTH = 2.8;
$HEIGHT = 1.9;
$XMIN = 0;
$YMIN = 0;
$YMAX = 100;
$YSTEP = 20;
# Fonts
$TITLE_FONT = "helvetica8b";
$GRAPH_FONT = "helvetica6";
$TIC_FONT = "helvetica4";
# Local IFDEF-like variables
$INCLUDE_KEY = 0;
#$DEBUG = 1; # Set to print out all kinds of info
$COLOR = 1; # Set to print pretty color graphs
$START_INDEX = 0;
# Constants for 2-D array
if ($old) {
$MAX_INDEX = 6;
$IDLE_INDEX = 5;
$USER_STALL_INDEX = 4;
$USER_INDEX = 3;
$SYS_SYNC_INDEX = 2;
$SYS_STALL_INDEX = 1;
$SYS_INDEX = 0;
$START_INDEX = $SYS_INDEX;
}
#################################################################
# Setup arrays containing information for each variable we are
# collecting data on.
#################################################################
if ($old) {
# Set up labels for the key
$LABEL[$IDLE_INDEX] = "Idle";
$LABEL[$USER_STALL_INDEX] = "User Stall";
$LABEL[$USER_INDEX] = "User";
$LABEL[$SYS_SYNC_INDEX] = "Kernel Sync";
$LABEL[$SYS_STALL_INDEX] = "Kernel Stall";
$LABEL[$SYS_INDEX] = "Kernel";
}
# Local Variables
$section = 0;
$clockRate = 0;
$GRAPH_TITLE = shift;
$type = "mp";
#################################################################
# Process the input file
#################################################################
while (<>) {
@fields = split('\t');
if( $section == 0 ) {
$startTime = $fields[0];
}
if (/NUMCPUs(.*)/) {
if ($1 == 1) {
print STDERR "Generating UP profile\n";
$type = "up";
} else {
print STDERR "Generating MP profile\n";
}
next;
}
if (/BREAKDOWN(.*)/) {
for $i (1..$#fields) {
$LABEL[$i-1] = $fields[$i];
}
$MAX_INDEX = $#fields;
print STDERR "time-profile: $MAX_INDEX categories\n";
next;
}
if (/COLOR(.*)/) {
for $i (1..$#fields) {
$COLOR[$i-1] = $fields[$i];
}
$MAX_INDEX = $#fields;
print STDERR "time-profile: $MAX_INDEX colors\n";
next;
}
if (/CLOCK(.*)/) {
$clockRate = $1;
next;
}
if (/USE_KEY(.*)/) {
$INCLUDE_KEY = 1;
print STDERR "time-profile: include key \n";
next;
}
$section++;
$TIME[$section] = $fields[0] - $startTime;
for ($var=$START_INDEX; $var < $MAX_INDEX; $var++) {
if( !defined($fields[$var+1])) {
print STDERR "NotDef \($fields[$var+1] \n";
}
$PERCENT[$section * $MAX_INDEX + $var] = $fields[$var+1];
}
$numSections = $section;
}
# Setup colors
if ($old) {
if ($COLOR == 1) {
$COLOR[$IDLE_INDEX] = "color white";
$COLOR[$USER_STALL_INDEX] = "color blue";
$COLOR[$USER_INDEX] = "color aquamarine";
$COLOR[$SYS_SYNC_INDEX] = "color red";
$COLOR[$SYS_STALL_INDEX] = "color yellow";
$COLOR[$SYS_INDEX] = "color green";
} else {
if (($type eq "up")) {
$COLOR[$IDLE_INDEX] = "gray 1.0";
$COLOR[$USER_STALL_INDEX] = "gray .1";
$COLOR[$USER_INDEX] = "gray .8";
$COLOR[$SYS_STALL_INDEX] = "gray .3";
$COLOR[$SYS_INDEX] = "gray .9";
} else {
$COLOR[$IDLE_INDEX] = "gray 1.0";
$COLOR[$USER_STALL_INDEX] = "gray .1";
$COLOR[$USER_INDEX] = "gray .8";
# $COLOR[$SYS_SYNC_INDEX] = "gray 1.0";
$COLOR[$SYS_STALL_INDEX] = "gray .3";
$COLOR[$SYS_INDEX] = "gray .9";
}
}
}
#################################################################
# Print the splot header
#################################################################
printf "new graph\n";
printf "size %3.2f by %3.2f\n", $WIDTH, $HEIGHT;
printf "graph font %s\n", $GRAPH_FONT;
# printf "graph title %s\n", $GRAPH_TITLE;
if ($INCLUDE_KEY == 1) {
if (($type eq "up")) {
printf "key %d, %d, both, %s\n", $TIME[$numSections]*.75, 130,
$GRAPH_FONT;
} else {
printf "key %d, %d, both, %s\n", $TIME[$numSections]*.75, 155,
$GRAPH_FONT;
}
}
#################################################################
# Main loop to print out the results
#################################################################
for ($i=$MAX_INDEX-1; $i >= $START_INDEX; $i--) {
# print the header for this region
printf("\nnew curve\n");
printf("curve label %s\n", $LABEL[$i]);
printf("curve type fill\n");
printf("curve %s\n", $COLOR[$i]);
printf "new points\n";
printf "%d, %.1f\n", 0, $PERCENT[$MAX_INDEX + $i];
for ($sec=1; $sec < $numSections; $sec++) {
printf "%d, %.1f\n", $TIME[$sec], $PERCENT[$sec * $MAX_INDEX + $i];
printf "%d, %.1f\n", $TIME[$sec], $PERCENT[($sec+1) * $MAX_INDEX + $i];
}
}
if ($GRAPH_TITLE ne "NOTITLE") {
$GRAPH_TITLE =~ s/_/ /g;
printf "\n\nnew text %d, %d\n", $TIME[$numSections]/2, 103;
printf "%s\n\n", $GRAPH_TITLE;
printf "text font %s\n", $TITLE_FONT;
printf "text align center\n\n";
}
#################################################################
# Print out trailer information
#################################################################
if ($clockRate != 0) {
$baseInt = $clockRate;
$xx =$TIME[$numSections] / $clockRate;
while ($xx > 20) {
$baseInt = $baseInt * 10;
$xx = $xx / 10;
}
printf "\nx label Time (seconds)\n";
printf "x unit %3.4f\n", 1.0/$clockRate;
printf "x interval %d\n", $baseInt;
} else {
printf "\nx label Cycles (millions)\n";
printf "x unit 1\n";
printf "x interval 500\n";
}
printf "x font %s\n", $GRAPH_FONT;
printf "x minimum %d\n", $XMIN;
printf "x tic font %s\n", $TIC_FONT;
printf "x maximum %d\n", $TIME[$numSections];
# printf "\nnew text %d, %d\n", $TIME[$numSections]*/2, 105;
# printf "%s\n\n", $GRAPH_TITLE;
printf "y label Percent of Execution Time\n";
printf "y tic font %s\n", $TIC_FONT;
printf "y font %s\n", $GRAPH_FONT;
printf "y minimum %d\n", $YMIN;
printf "y maximum %d\n", $YMAX;
printf "y interval %d\n", $YSTEP;
printf "exclude mirror labels\n";