Skip to content
This repository
tree: 54ae824332

Fetching latest commit…

Cannot retrieve the latest commit at this time

google-perftools for ruby code
  (c) 2009 Aman Gupta (tmm1)

=== Usage

  Run the profiler with a block:

    require 'perftools'
    PerfTools::CpuProfiler.start("/tmp/add_numbers_profile") do
      5_000_000.times{ 1+2+3+4+5 }

  Start and stop the profiler manually:

    require 'perftools'
    5_000_000.times{ 1+2+3+4+5 }

  Profile an existing ruby application without modifying it:

    $ CPUPROFILE=/tmp/my_app_profile RUBYOPT="-r`gem which perftools | tail -1`" ruby my_app.rb

=== Reporting

  pprof.rb --text /tmp/add_numbers_profile

  pprof.rb --pdf /tmp/add_numbers_profile > /tmp/add_numbers_profile.pdf

  pprof.rb --gif /tmp/add_numbers_profile > /tmp/add_numbers_profile.gif

  pprof.rb --callgrind /tmp/add_numbers_profile > /tmp/add_numbers_profile.grind
  kcachegrind /tmp/add_numbers_profile.grind

  pprof.rb --gif --focus=Integer /tmp/add_numbers_profile > /tmp/add_numbers_custom.gif

  pprof.rb --text --ignore=require /tmp/add_numbers_profile

=== Sample profiles vs    vs

=== Installation

  You'll need a patched version of Ruby 1.8:

    wget http://.../ruby-1.8.XpYYY.tar.gz
    tar zxvf ruby-1.8....
    cd ruby-1.8....

    patch -p1 ruby.patch

    ./configure --prefix=/opt/ruby-profiling
    sudo make install

  Install rubygems:

    tar zxvf rubygems-1.3.4.tgz
    cd rubygems-1.3.4
    /opt/ruby-profiling/bin/ruby setup.rb

  Install the perftools.rb gem, which will download and compile google-perftools for you:

    git clone git://
    cd perftools.rb
    gem build perftools.rb.gemspec
    /opt/ruby-profiling/bin/gem install perftools.rb

=== TODO

  * Add support for heap profiling to find memory leaks

=== Resources

  Google Perftools

  Analyzing profiles and interpreting different output formats
Something went wrong with that request. Please try again.