def benchmark(times = 1, &block)
      elapsed = (1..times).collect do
        GC.start
        ::Benchmark.realtime(&block) * times
      end

      Result.new(elapsed)
    end
def benchmark(times = 1, &block)
      elapsed = (1..times).collect do
        GC.start
        ::Benchmark.realtime(&block) * times
      end

      Result.new(elapsed)
    end
Run a given block and calculate the average execution time.
 The block will be executed 1 times by default.

   benchmark { do something }
   benchmark(100) { do something }