time-profile.prl
来自「一个用在mips体系结构中的操作系统」· PRL 代码 · 共 182 行
PRL
182 行
#!/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";
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?