commit 854514f356fd25bbb30b8e6fb06cac137f5a464a
parent 8ab3b5b0336b5dcf1cc4b4e5ae11bcf3ce9cf0e5
Author: Brendan Gregg <brendan.d.gregg@gmail.com>
Date: Sun, 18 Sep 2022 10:32:41 +1000
Merge pull request #284 from jayrhynas/instruments-update
stackcollapse-instruments: Update to handle "Deep Copy" format
Diffstat:
1 file changed, 15 insertions(+), 7 deletions(-)
diff --git a/stackcollapse-instruments.pl b/stackcollapse-instruments.pl
@@ -2,8 +2,8 @@
#
# stackcollapse-instruments.pl
#
-# Parses a CSV file containing a call tree as produced by XCode
-# Instruments and produces output suitable for flamegraph.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
@@ -14,13 +14,21 @@ my @stack = ();
<>;
foreach (<>) {
chomp;
- /\d+\.\d+ms[^,]+,(\d+(?:\.\d*)?),\s+,(\s*)(.+)/ or die;
- my $func = $3;
- my $depth = length ($2);
- $stack [$depth] = $3;
+ /\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 ";";
}
- print "$func $1\n";
+
+ my $time = 0 + $1;
+ if ($2 eq "min") {
+ $time *= 60*1000;
+ } elsif ($2 eq "s") {
+ $time *= 1000;
+ }
+
+ printf("%s %.0f\n", $func, $time);
}