Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Comparing changes

Choose two branches to see what's changed or to start a new pull request. If you need to, you can also compare across forks.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also compare across forks.
base fork: brendangregg/FlameGraph
base: e0fbd11f39
...
head fork: brendangregg/FlameGraph
compare: 0bc421a3a6
  • 2 commits
  • 1 file changed
  • 0 commit comments
  • 2 contributors
Commits on Mar 17, 2013
@timbunce timbunce Optimize flow anlysis (~25% faster). Report count of skipped lines, i…
…f any.

Using dumbench (https://metacpan.org/module/Dumbbench) to run flamegraph
on a file with ~140,000 lines:
old: Rounded run time per iteration: 3.472e+00 +/- 1.7e-02 (0.5%)
new: Rounded run time per iteration: 2.618e+00 +/- 1.3e-02 (0.5%)
daa7cf6
@brendangregg Merge pull request #10 from timbunce/optimize
Optimize flow analysis (~25% faster). Report count of skipped lines, if any.
0bc421a
Showing with 20 additions and 19 deletions.
  1. +20 −19 flamegraph.pl
View
39 flamegraph.pl
@@ -152,53 +152,54 @@ sub color {
my %Tmp;
sub flow {
- my ($a, $b, $v) = @_;
- my @A = split ";", $a;
- my @B = split ";", $b;
+ my ($last, $this, $v) = @_;
- my $len_a = $#A;
- my $len_b = $#B;
+ my $len_a = @$last - 1;
+ my $len_b = @$this - 1;
$depthmax = $len_b if $len_b > $depthmax;
my $i = 0;
- my $len_same = 0;
+ my $len_same;
for (; $i <= $len_a; $i++) {
last if $i > $len_b;
- last if $A[$i] ne $B[$i];
+ last if $last->[$i] ne $this->[$i];
}
$len_same = $i;
for ($i = $len_a; $i >= $len_same; $i--) {
- my $k = "$A[$i]--$i";
+ my $k = "$last->[$i]--$i";
# a unique ID is constructed from func--depth--etime;
# func-depth isn't unique, it may be repeated later.
- $Node{"$k--$v"}->{stime} = $Tmp{$k}->{stime};
- delete $Tmp{$k}->{stime};
+ $Node{"$k--$v"}->{stime} = delete $Tmp{$k}->{stime};
delete $Tmp{$k};
}
for ($i = $len_same; $i <= $len_b; $i++) {
- my $k = "$B[$i]--$i";
+ my $k = "$this->[$i]--$i";
$Tmp{$k}->{stime} = $v;
}
+
+ return $this;
}
# Parse input
my @Data = <>;
-my $last = "";
+my $last = [];
my $time = 0;
+my $ignored = 0;
foreach (sort @Data) {
chomp;
my ($stack, $samples) = (/^(.*)\s+(\d+)$/);
- $stack =~ s/</(/g;
- $stack =~ s/>/)/g;
- $stack = ";$stack";
- next unless defined $samples;
- flow($last, $stack, $time);
+ unless (defined $samples) {
+ ++$ignored;
+ next;
+ }
+ $stack =~ tr/<>/()/;
+ $last = flow($last, [ '', split ";", $stack ], $time);
$time += $samples;
- $last = $stack;
}
-flow($last, "", $time);
+flow($last, [], $time);
+warn "Ignored $ignored lines with invalid format\n" if $ignored;
$timemax = $time or die "ERROR: No stack counts found\n";
# Draw canvas

No commit comments for this range

Something went wrong with that request. Please try again.