Skip to content
This repository
Browse code

safety bench

  • Loading branch information...
commit 84e8559b8eb31e9eee304dc81c54d6966fa95608 1 parent 915e761
Kenichi Kamiya authored April 15, 2012

Showing 1 changed file with 17 additions and 9 deletions. Show diff stats Hide diff stats

  1. 26  example/benchmark.rb
26  example/benchmark.rb
@@ -14,7 +14,7 @@ def initialize(looks, price, other=nil)
14 14
 end
15 15
 
16 16
 class HeavyParts
17  
-  DATA = 'str' * 10000000
  17
+  DATA = 'str' * 100000000
18 18
   
19 19
   def initialize
20 20
     @content = DATA.dup
@@ -25,50 +25,58 @@ def initialize
25 25
 
26 26
 Benchmark.bm do |bm| 
27 27
   bm.report 'Light Instant .new' do
  28
+    klass = Class.new Material
28 29
     TIMES.times do
29  
-      Material.new :metal, 2000
  30
+      klass.new :metal, 2000
30 31
     end
31 32
   end
32 33
   
33 34
   bm.report 'Light Instant .intern' do
  35
+    klass = Class.new Material
34 36
     TIMES.times do
35  
-      Material.intern :metal, 2000
  37
+      klass.intern :metal, 2000
36 38
     end
37 39
   end
38 40
   
39 41
   bm.report 'Light Keep .new' do
  42
+    klass = Class.new Material
40 43
     TIMES.times.map do
41  
-      Material.new :metal, 2000
  44
+      klass.new :metal, 2000
42 45
     end
43 46
   end
44 47
   
45 48
   bm.report 'Light Keep .intern' do
  49
+    klass = Class.new Material
46 50
     TIMES.times.map do
47  
-      Material.intern :metal, 2000
  51
+      klass.intern :metal, 2000
48 52
     end
49 53
   end
50 54
 
51 55
   bm.report 'Heavy Instant .new' do
  56
+    klass = Class.new Material
52 57
     TIMES.times do
53  
-      Material.new :metal, 2000, HeavyParts.new
  58
+      klass.new :metal, 2000, HeavyParts.new
54 59
     end
55 60
   end
56 61
   
57 62
   bm.report 'Heavy Instant .intern' do
  63
+    klass = Class.new Material
58 64
     TIMES.times do
59  
-      Material.intern :metal, 2000, HeavyParts.new
  65
+      klass.intern :metal, 2000, HeavyParts.new
60 66
     end
61 67
   end
62 68
   
63 69
   bm.report 'Heavy Keep .new' do
  70
+    klass = Class.new Material
64 71
     TIMES.times.map do
65  
-      Material.new :metal, 2000, HeavyParts.new
  72
+      klass.new :metal, 2000, HeavyParts.new
66 73
     end
67 74
   end
68 75
   
69 76
   bm.report 'Heavy Keep .intern' do
  77
+    klass = Class.new Material
70 78
     TIMES.times.map do
71  
-      Material.intern :metal, 2000, HeavyParts.new
  79
+      klass.intern :metal, 2000, HeavyParts.new
72 80
     end
73 81
   end
74 82
 end

0 notes on commit 84e8559

Please sign in to comment.
Something went wrong with that request. Please try again.