Created
January 10, 2012 18:13
-
-
Save cball/1590325 to your computer and use it in GitHub Desktop.
How to use perftools.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# generate profile around a script/test | |
$ CPUPROFILE=/tmp/my_app_profile RUBYOPT="-r`gem which perftools | tail -1`" ruby -I spec spec/models/user_role_spec.rb | |
# generate profile using a block | |
# (this is in ruby obviously) | |
require 'perftools' | |
PerfTools::CpuProfiler.start("/tmp/add_numbers_profile") do | |
5_000_000.times{ 1+2+3+4+5 } | |
end | |
# show as text | |
$ pprof.rb --text /tmp/my_app_profile | |
# show as gif | |
$ pprof.rb --gif /tmp/my_app_profile > /tmp/my_app_profile.gif | |
# if that fails, | |
$ brew install graphviz ghostscript |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# generate profile around a script/test | |
$ CPUPROFILE=/tmp/my_app_profile RUBYOPT="-r`gem which perftools | tail -1`" ruby -I spec spec/models/user_role_spec.rb | |
# generate profile using a block | |
# (this is in ruby obviously) | |
require 'perftools' | |
PerfTools::CpuProfiler.start("/tmp/add_numbers_profile") do | |
5_000_000.times{ 1+2+3+4+5 } | |
end | |
# show as text | |
$ pprof.rb --text /tmp/my_app_profile | |
# show as gif | |
$ pprof.rb --gif /tmp/my_app_profile > /tmp/my_app_profile.gif | |
# if that fails, | |
$ brew install graphviz ghostscript |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment