mirror of
https://github.com/libgit2/libgit2.git
synced 2026-01-25 11:06:32 +00:00
Introduce `--profile` support to the benchmark helper script, which will invoke `perf` on Linux. Additionally, add a `--flamegraph` output option based on that.
35 lines
680 B
Perl
Executable File
35 lines
680 B
Perl
Executable File
#!/usr/bin/perl -w
|
|
#
|
|
# stackcollapse-instruments.pl
|
|
#
|
|
# Parses a file containing a call tree as produced by XCode Instruments
|
|
# (Edit > Deep Copy) and produces output suitable for flamegraph.pl.
|
|
#
|
|
# USAGE: ./stackcollapse-instruments.pl infile > outfile
|
|
|
|
use strict;
|
|
|
|
my @stack = ();
|
|
|
|
<>;
|
|
foreach (<>) {
|
|
chomp;
|
|
/\d+\.\d+ (?:min|s|ms)\s+\d+\.\d+%\s+(\d+(?:\.\d+)?) (min|s|ms)\t \t(\s*)(.+)/ or die;
|
|
my $func = $4;
|
|
my $depth = length ($3);
|
|
$stack [$depth] = $4;
|
|
foreach my $i (0 .. $depth - 1) {
|
|
print $stack [$i];
|
|
print ";";
|
|
}
|
|
|
|
my $time = 0 + $1;
|
|
if ($2 eq "min") {
|
|
$time *= 60*1000;
|
|
} elsif ($2 eq "s") {
|
|
$time *= 1000;
|
|
}
|
|
|
|
printf("%s %.0f\n", $func, $time);
|
|
}
|