Introduction

Profiling tells you what code is taking what amount of time.

For example, you can find out which a single line of code is causing the program to run slowly.

Ruby has a code profiler built in.

Demo

require 'profile' 
class Calculator 
  def self.count_to_large_number 
         x = 0 # from   w ww .jav  a2  s . com
         100000.times { x += 1 } 
  end 

  def self.count_to_small_number 
    x = 0 
    1000.times { x += 1 } 
  end 
end 

Calculator.count_to_large_number 
Calculator.count_to_small_number

Result

Related Topic