benchmarks/wrap_test.rb in contracts-0.7 vs benchmarks/wrap_test.rb in contracts-0.8
- old
+ new
@@ -1,6 +1,6 @@
-require 'benchmark'
+require "benchmark"
module Wrapper
def self.extended(klass)
klass.class_eval do
@@methods = {}
@@ -24,36 +24,34 @@
}, __FILE__, __LINE__ + 1
end
end
class NotWrapped
-def add a, b
- a + b
+ def add a, b
+ a + b
+ end
end
-end
class Wrapped
extend ::Wrapper
def add a, b
a + b
end
end
-
w = Wrapped.new
nw = NotWrapped.new
-#p w.add(1, 4)
-#exit
+# p w.add(1, 4)
+# exit
# 30 is the width of the output column
Benchmark.bm 30 do |x|
- x.report 'wrapped' do
- 100000.times do |_|
+ x.report "wrapped" do
+ 100_000.times do |_|
w.add(rand(1000), rand(1000))
end
end
- x.report 'not wrapped' do
- 100000.times do |_|
- nw.add(rand(1000), rand(1000))
+ x.report "not wrapped" do
+ 100_000.times do |_|
+ nw.add(rand(1000), rand(1000))
end
end
end
-