title: Low-overhead Ruby profiling?
body: <p>I have a Ruby program that takes about 4 minutes to complete task and I'd like to get it down to under 1 minute.</p>
  
  <p>I tried ruby-prof from gem but enabling it increases running times to ~30 minutes, and doesn't even seem to preserve monotonicity particularly well (some changes reliably improve performance-with-profiler and as reliably deteriorate performance-without-profiler). This task also cannot really be broken down into parts that can be meaningfully profiled independently.</p>
  
  <p>What's the current best way to profile Ruby code with lowest overhead?</p>
  
  <p>I use OSX, but if for any reason profiler requires another OS, I might reboot.</p>
  
  <p>EDIT: <code>perftools.rb</code> has much lower overhead, but results look rather dubious to be honest, way outside any reasonable sampling error - at the very least it must be messing with GC or i/o buffering or something like that, causing a lot of silly misattributions. It still beats ruby-prof.</p>
  
  <p>I'll keep the question open in case someone knows anything better than that.</p>