time-profile.prl
5.32 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
#!/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)
# Graph Variables
$WIDTH = 2.8;
$HEIGHT = 1.9;
$XMIN = 0;
$YMIN = 0;
$YMAX = 0;
# 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;
# Local Variables
$section = 0;
$clockRate = 0;
$GRAPH_TITLE = shift;
$XMAX = shift;
#################################################################
# Process the input file
#################################################################
while (<>) {
@fields = split('\t');
if (/^BREAKDOWN/) {
for $i (1..$#fields) {
$LABEL[$i-1] = $fields[$i];
}
$MAX_INDEX = $#fields;
# print STDERR "time-profile: $MAX_INDEX categories\n";
next;
} elsif (/^COLOR/) {
for $i (1..$#fields) {
$COLOR[$i-1] = $fields[$i];
}
$MAX_INDEX = $#fields;
# print STDERR "time-profile: $MAX_INDEX colors\n";
next;
} elsif (/^CLOCK/) {
$clockRate = $';
next;
} elsif (/^USE_KEY/) {
$INCLUDE_KEY = 1;
# print STDERR "time-profile: include key \n";
next;
}
$section++;
$TIME[$section] = $fields[0];
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;
}
#################################################################
# Either get XMAX from command line (for comparable graphs)
# or set as end of run.
# Command line arg is in seconds so convert to clock cycles.
#################################################################
if (($XMAX eq "FLOATING") || ($XMAX eq "")) {
$XMAX = $TIME[$numSections];
} else {
$XMAX = $XMAX * $clockRate;
}
#################################################################
# 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) {
printf "key %d, %d, both, %s\n", $XMAX*1.02, 100,
$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];
}
printf "%d, %.1f\n", $TIME[$numSections], $PERCENT[($numSections)*$MAX_INDEX + $i];
}
if ($GRAPH_TITLE ne "NOTITLE") {
$GRAPH_TITLE =~ s/_/ /g;
printf "\n\nnew text %d, %d\n", $XMAX/2, 103;
printf "%s\n\n", $GRAPH_TITLE;
printf "text font %s\n", $TITLE_FONT;
printf "text align center\n\n";
}
#################################################################
# Calculate YMAX to scale to max y value
#################################################################
for ($sec=1; $sec <= $numSections; $sec++) {
$indx = $sec * $MAX_INDEX + $MAX_INDEX - 1;
$YMAX = ($PERCENT[$indx] > $YMAX) ? $PERCENT[$indx] : $YMAX;
}
#################################################################
# Print out trailer information
#################################################################
@intVals = ('0.05', '0.1', '0.25', '0.5', '1', '2.5', '5', '10', '25', '50', '100', '250', '500', '1000', '10000');
@decDigits = ('2', '1', '2', '1', '0', '1', '0', '0', '0', '0', '0', '0', '0', '0', '0');
$co = 0;
while ($intVals[$co]*$clockRate*10 < $XMAX) {
$co++;
}
$interval = $intVals[$co]*$clockRate;
$decimals = $decDigits[$co];
if ($clockRate != 0) {
printf "\nx label Time (seconds)\n";
printf "x unit %7.5f\n", 1.0/$clockRate;
printf "x interval %d\n", $interval;
printf "x numberstyle floating %d\n", $decimals;
} else {
printf "\nx label Cycles (millions)\n";
printf "x unit 1\n";
printf "x interval %d\n", $interval;
}
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", $XMAX;
# printf "\nnew text %d, %d\n", $XMAX*/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 %.2f\n", $YMAX;
printf "y interval %d\n", ($YMAX - $YMIN) / 5;
printf "exclude mirror labels\n";