Module: Stud::Benchmark

Defined in:
lib/stud/benchmark.rb

Defined Under Namespace

Classes: Results

Class Method Summary collapse

Class Method Details

.run(iterations = 1, &block) ⇒ Object



8
9
10
11
12
13
14
15
16
17
18
19
20
# File 'lib/stud/benchmark.rb', line 8

def self.run(iterations=1, &block)
  i = 0
  data = []
  full_start = Time.now
  while i < iterations
    start = Time.now
    block.call
    duration = Time.now - start
    data << duration
    i += 1
  end
  return Results.new(data)
end