mirror of
https://github.com/lloeki/ruby-benchmarks.git
synced 2025-12-06 08:54:39 +01:00
Use benchmark-ips
This commit is contained in:
parent
484269dba2
commit
f42114b16a
4 changed files with 34 additions and 5 deletions
|
|
@ -1,6 +1,7 @@
|
|||
#!/usr/bin/env ruby
|
||||
# frozen_string_literal: true
|
||||
|
||||
require 'benchmark'
|
||||
require 'benchmark/ips'
|
||||
|
||||
class Example
|
||||
def initialize
|
||||
|
|
@ -20,10 +21,15 @@ class Example
|
|||
end
|
||||
end
|
||||
|
||||
Benchmark.bm(12) do |x|
|
||||
Benchmark.ips do |x|
|
||||
x.time = 5
|
||||
x.warmup = 0.5
|
||||
|
||||
ex = Example.new
|
||||
n = 10_000_000
|
||||
|
||||
x.report('block') { n.times { ex.using_block } }
|
||||
x.report('ensure') { n.times { ex.using_ensure } }
|
||||
|
||||
x.compare!
|
||||
end
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue