cheat sheets.

$ cheat rubyprof
Installation
------------
sudo gem install ruby-prof


Usage
-----
Without changing your code:

  $ 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::FlatPrinter.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
-------------------
In your code:

  RubyProf.clock_mode = RubyProf::PROCESS_TIME
  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
---------------
Available printer types:

  RubyProf::FlatPrinter - flat report in text format
  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
---------------------
In your code:

  RubyProf.cpu_frequency = <value>

Or in your environment:

  export RUBY_PROF_CPU_FREQUENCY=<value>
Version 2, updated 375 days ago.
. o 0 ( | previous | history | revert to | current | diff )
( add new | see all )