Top Level Namespace

Defined Under Namespace

Modules: PryMeasure

Instance Method Summary collapse

Instance Method Details

#pry_measure(test_times = 10, exec_times = 1, &b) ⇒ Object



12
13
14
15
16
17
18
19
20
21
22
# File 'lib/pry-measure/helper_methods.rb', line 12

def pry_measure(test_times = 10, exec_times = 1, &b)
  Benchmark.bm do |x|
    test_times.times do
      x.report do
        exec_times.times do
          yield
        end
      end
    end
  end
end

#time_method(object, method, *args) ⇒ Object



5
6
7
8
9
10
# File 'lib/pry-measure/helper_methods.rb', line 5

def time_method(object, method, *args)
  beginning_time = Time.now
  object.send(method, *args)
  end_time = Time.now
  puts "Time elapsed #{(end_time - beginning_time)*1000} milliseconds"
end