Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add --total option to enable visualization of time spent not within a sub #14

Merged
merged 1 commit into from
Mar 25, 2013
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 11 additions & 2 deletions flamegraph.pl
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@
my $nametype = "Function:"; # what are the names in the data?
my $countname = "samples"; # what are the counts in the data?
my $nameattrfile; # file holding function attributes
my $timemax; # (override the) sum of the counts

GetOptions(
'fonttype=s' => \$fonttype,
Expand All @@ -76,14 +77,14 @@
'nametype=s' => \$nametype,
'countname=s' => \$countname,
'nameattr=s' => \$nameattrfile,
'total=s' => \$timemax,
) or exit 1;


# internals
my $ypad1 = $fontsize * 4; # pad top, include title
my $ypad2 = $fontsize * 2 + 10; # pad bottom, include labels
my $xpad = 10; # pad lefm and right
my $timemax = 0;
my $depthmax = 0;
my %Events;
my %nameattr;
Expand Down Expand Up @@ -243,7 +244,13 @@ sub flow {
}
flow($last, [], $time);
warn "Ignored $ignored lines with invalid format\n" if $ignored;
$timemax = $time or die "ERROR: No stack counts found\n";
die "ERROR: No stack counts found\n" unless $time;

if ($timemax and $timemax < $time) {
warn "Specified --total $timemax is less than actual total $time, so ignored\n";
undef $timemax;
}
$timemax ||= $time;

# Draw canvas
my $widthpertime = ($imagewidth - 2 * $xpad) / $timemax;
Expand Down Expand Up @@ -286,6 +293,8 @@ sub flow {
die "missing start for $id" if !defined $Node{$id}->{stime};
my $stime = $Node{$id}->{stime};

$etime = $timemax if $func eq "" and $depth == 0;

my $x1 = $xpad + $stime * $widthpertime;
my $x2 = $xpad + $etime * $widthpertime;
my $width = $x2 - $x1;
Expand Down