📄 mt-time-profile.prl
字号:
#!/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 arrayif ($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 colorsif ($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";
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -