2

The best match that I have found until now is to use ruby-prof from command line and try to guess the graph reading from there.

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)

https://github.com/rdp/ruby-prof

The main problem with this approach is that you have to modify your code to see the profiling and is not very readable.

Also I have tried if some IDEs: RubyMine, Aptana and Netbeans and no one has a proper graphical interface to profile code.

Any recommendation?

user989959
  • 21
  • 3

2 Answers2

3

Try the ruby-prof command line tool: http://ruby-prof.rubyforge.org/files/bin/ruby-prof.html

And use something like following:

ruby-prof -p graph_html -f filename.html rubycode.rb
Amar
  • 11,930
  • 5
  • 50
  • 73
1

Checkout mini-profiler: http://railscasts.com/episodes/368-miniprofiler

Documentation can be found here: https://github.com/SamSaffron/MiniProfiler/tree/master/Ruby

Checkout special parameter: pp=flamegraph - it's amazingly easy to profile. For ruby 2.0 it works even on production!

Dmitry Polushkin
  • 3,283
  • 1
  • 38
  • 44