November 2015
Intermediate to advanced
200 pages
4h 26m
English
ruby-prof is a Ruby gem that comes with both an API and a command-line tool. In most cases you’ll probably want use the API to profile just that isolated part of the code that you suspect to be slow. But the command-line tool is what you want for profiling application startup, especially if you’re interested in rubygems startup costs. In Rails applications you can get the complete request profile by inserting ruby-prof into the middleware stack.
In this example we’ll use the ruby-prof API to profile a specific part of your code.
| chp4/ruby_prof_example_api1.rb | |
| | require 'date' |
| | require 'rubygems' |
| | require 'ruby-prof' |
| | |
| | GC.disable |
| | |
| | RubyProf.start |
| | Date.parse("2014-07-01") |
| | result = RubyProf.stop ... |
Read now
Unlock full access