Permalink
Switch branches/tags
Nothing to show
Find file
Fetching contributors…
Cannot retrieve contributors at this time
72 lines (47 sloc) 1.47 KB
Installation
------------
sudo gem install ruby-prof
Usage
--
$ ruby-prof your_ruby_app.rb
Or, inside your code:
require 'ruby-prof'
# Profile the code
RubyProf.start
...
[code to profile]
...
result = RubyProf.stop
# Print a flat profile to text
printer = RubyProf::TextPrinter.new(result)
printer.print(STDOUT, 0)
Or, use a block to tell ruby-prof what to profile:
require 'ruby-prof'
# Profile the code
result = RubyProf.profile do
...
[code to profile]
...
end
# Print a graph profile to text
printer = RubyProf::GraphPrinter.new(result)
printer.print(STDOUT, 0)
Or, the old way:
require 'unprof'
Setting Clock Modes
------------- RubyProf.clock_mode = RubyProf::WALL_TIME
RubyProf.clock_mode = RubyProf::CPU_TIME
Or, via environment variable:
export RUBY_PROF_CLOCK_MODE=(process|wall|cpu)
Printing Graphs
--------- RubyProf::GraphPrinter - call graph report in text format
RubyProf::GraphHtmlPrinter - call graph report in HTML (one file per thread)
In your code:
result = RubyProf.end
printer = RubyProf::GraphPrinter.new(result)
printer.print(STDOUT, 0)
Setting CPU Frequency
------------------
RubyProf.cpu_frequency = <value>
Or in your environment:
export RUBY_PROF_CPU_FREQUENCY=<value>