0Pricing
Ruby Academy · Lesson

Profiling Tools

ruby-prof and stackprof.

Benchmark vs Profiler

A benchmark tells you how long something takes. A profiler tells you where the time goes inside it.

  • Profilers break time down per method or line
  • They reveal hotspots you would never guess
  • Popular Ruby profilers: ruby-prof and stackprof
# Profilers answer: which method consumed the most time?
puts 'Benchmark = how long, Profiler = where'

ruby-prof Overview

ruby-prof is a detailed instrumenting profiler. It hooks into every method call.

  • Very precise call counts and timings
  • Higher overhead, so use on representative samples
  • Installed with gem install ruby-prof
# Gemfile
gem 'ruby-prof'

All lessons in this course

  1. Measuring Performance
  2. Profiling Tools
  3. Memory Optimization
  4. Common Bottlenecks
← Back to Ruby Academy