Permalink
Browse files

safety bench

  • Loading branch information...
1 parent 915e761 commit 84e8559b8eb31e9eee304dc81c54d6966fa95608 @kachick committed Apr 14, 2012
Showing with 17 additions and 9 deletions.
  1. +17 −9 example/benchmark.rb
View
@@ -14,7 +14,7 @@ def initialize(looks, price, other=nil)
end
class HeavyParts
- DATA = 'str' * 10000000
+ DATA = 'str' * 100000000
def initialize
@content = DATA.dup
@@ -25,50 +25,58 @@ def initialize
Benchmark.bm do |bm|
bm.report 'Light Instant .new' do
+ klass = Class.new Material
TIMES.times do
- Material.new :metal, 2000
+ klass.new :metal, 2000
end
end
bm.report 'Light Instant .intern' do
+ klass = Class.new Material
TIMES.times do
- Material.intern :metal, 2000
+ klass.intern :metal, 2000
end
end
bm.report 'Light Keep .new' do
+ klass = Class.new Material
TIMES.times.map do
- Material.new :metal, 2000
+ klass.new :metal, 2000
end
end
bm.report 'Light Keep .intern' do
+ klass = Class.new Material
TIMES.times.map do
- Material.intern :metal, 2000
+ klass.intern :metal, 2000
end
end
bm.report 'Heavy Instant .new' do
+ klass = Class.new Material
TIMES.times do
- Material.new :metal, 2000, HeavyParts.new
+ klass.new :metal, 2000, HeavyParts.new
end
end
bm.report 'Heavy Instant .intern' do
+ klass = Class.new Material
TIMES.times do
- Material.intern :metal, 2000, HeavyParts.new
+ klass.intern :metal, 2000, HeavyParts.new
end
end
bm.report 'Heavy Keep .new' do
+ klass = Class.new Material
TIMES.times.map do
- Material.new :metal, 2000, HeavyParts.new
+ klass.new :metal, 2000, HeavyParts.new
end
end
bm.report 'Heavy Keep .intern' do
+ klass = Class.new Material
TIMES.times.map do
- Material.intern :metal, 2000, HeavyParts.new
+ klass.intern :metal, 2000, HeavyParts.new
end
end
end

0 comments on commit 84e8559

Please sign in to comment.