Skip to content

Instantly share code, notes, and snippets.

@tarui
Created October 21, 2017 06:27
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tarui/aa0e0d036b9a683f668ec258ea24052c to your computer and use it in GitHub Desktop.
Save tarui/aa0e0d036b9a683f668ec258ea24052c to your computer and use it in GitHub Desktop.
analyze_vm_exec_core_by_perf.rb
data=`perf annotate -svm_exec_core --show-total-period --stdio`.split(/\n/)
ins="before"
cnt=Hash.new{0}
total=0
data.each{|line|
case line
when /INSN_ENTRY\((.*)\)/
ins = $1
when /END_INSN/
ins = "none"
end
if line =~/^\s*([\d\.]+)\s*:/
cnt[ins] += $1.to_i
total += $1.to_i
end
}
cnt.each{|k,v| cnt[k]=v.to_f/total}
require 'pp'
pp cnt.to_a.map{|a,b| [b,a]}.sort
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment