commit be7d6b92e3384b2fcf3c328444f31cf4448808ad
parent 375b27a16cfa9f48a42b2afd618dfecf0e0246ff
Author: Brendan Gregg <brendan.d.gregg@gmail.com>
Date: Mon, 30 Aug 2021 21:34:10 -0700
Merge pull request #149 from rohith14/master
Add support for different VTune versions
Diffstat:
1 file changed, 40 insertions(+), 21 deletions(-)
diff --git a/stackcollapse-vtune.pl b/stackcollapse-vtune.pl
@@ -9,17 +9,17 @@
# WORKFLOW:
#
# This assumes you have Intel VTune installed and on path (using Command Line)
-#
+#
# 1. Profile C++ application tachyon_find_hotspots (example shipped with Intel VTune 2013):
#
# amplxe-cl -collect hotspots -r result_vtune_tachyon -- ./tachyon_find_hotspots
#
# 2. Export raw VTune data to csv file:
-# ###for Intel VTune 2013
-# amplxe-cl -R top-down -call-stack-mode all -report-out result_vtune_tachyon.csv -filter "Function Stack" -format csv -csv-delimiter comma -r result_vtune_tachyon
-#
-# ###for Intel VTune 2015 & 2016
-# amplxe-cl -R top-down -call-stack-mode all -column="CPU Time:Self","Module" -report-out result_vtune_tachyon.csv -filter "Function Stack" -format csv -csv-delimiter comma -r result_vtune_tachyon
+#
+##### VTune 2013 & 2015
+# amplxe-cl -R top-down -report-out result_vtune_tachyon.csv -filter "Function Stack" -format csv -csv-delimiter comma -r result_vtune_tachyon
+#### VTune 2016
+# amplxe-cl.exe -R top-down -call-stack-mode all -column="CPU Time:Self","Module" -report-output result_vtune_tachyon.csv -filter "Function Stack" -format csv -csv-delimiter comma -r result_vtune_tachyon
#
# 3. Generate a flamegraph:
#
@@ -42,6 +42,10 @@ exit;
}
my $inputCSVFile = $ARGV[0];
+my $funcOnly = '';
+my $depth = 0;
+my $selfTime = 0;
+my $dllName = '';
open(my $fh, '<', $inputCSVFile) or die "Can't read file '$inputCSVFile' [$!]\n";
@@ -50,28 +54,43 @@ while (my $currLine = <$fh>){
# to discard first row which typically contains headers
next if $rowCounter == 1;
chomp $currLine;
- #VTune - sometimes the call stack information is enclosed in double quotes (?). To remove double quotes.
+
+ ### VTune 2013 & 2015
+ #VTune - sometimes the call stack information is enclosed in double quotes (?). To remove double quotes. Not necessary for XCode instruments (MAC)
$currLine =~ s/\"//g;
-
- ### for Intel VTune 2013
- #$currLine =~ /(\s*)(.*),(.*),[0-9]*\.?[0-9]+[%],([0-9]*\.?[0-9]+)/ or die "Error in regular expression on the current line\n";
- #my $func = $3.'!'.$2;
- #my $depth = length ($1);
- #my $selfTime = $4*1000; # selfTime in msec
-
- ### for Intel VTune 2015 & 2016
- $currLine =~ /(\s*)(.*?),([0-9]*\.?[0-9]+?),(.*)/ or die "Error in regular expression on the current line $currLine\n";
- my $func = $4.'!'.$2;
- my $depth = length ($1);
- my $selfTime = $3*1000; # selfTime in msec
-
+ $currLine =~ /(\s*)(.*),(.*),.*,([0-9]*\.?[0-9]+)/ or die "Error in regular expression on the current line\n";
+ $dllName = $3;
+ $func = $dllName.'!'.$2; # Eg : m_lxe.dll!MathWorks::lxe::IrEngineDecorator::Apply
+ $depth = length ($1);
+ $selfTime = $4*1000; # selfTime in msec
+ ### VTune 2013 & 2015
+
+ ### VTune 2016
+ # $currLine =~ /(\s*)(.*?),([0-9]*\.?[0-9]+?),(.*)/ or die "Error in regular expression on the current line $currLine\n";
+ # if ($2 =~ /\"/)
+ # {
+ # $currLine =~ /(\s*)\"(.*?)\",([0-9]*\.?[0-9]+?),(.*)/ or die "Error in regular expression on the current line $currLine\n";
+ # $funcOnly = $2;
+ # $depth = length ($1);
+ # $selfTime = $3*1000; # selfTime in msec
+ # $dllName = $4;
+ # }
+ # else
+ # {
+ # $funcOnly = $2;
+ # $depth = length ($1);
+ # $selfTime = $3*1000; # selfTime in msec
+ # $dllName = $4;
+ # }
+ # my $func = $dllName.'!'.$funcOnly; # Eg : m_lxe.dll!MathWorks::lxe::IrEngineDecorator::Apply
+ ### VTune 2016
+
my $tempString = '';
$stack [$depth] = $func;
foreach my $i (0 .. $depth - 1) {
$tempString = $tempString.$stack[$i].";";
}
$tempString = $tempString.$func." $selfTime\n";
-
if ($selfTime != 0){
print "$tempString";
}