public
Description: a 1.8.6 compatible version of why's mixico lib + thread safety
Homepage:
Clone URL: git://github.com/coderrr/mixico-inline.git
mixico-inline / test / benchmarks.rb
100644 32 lines (24 sloc) 0.468 kb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
require 'benchmark'
require File.dirname(__FILE__) + '/../lib/mixico'
 
 
m = Module.new do
  def x;end
end
 
l = lambda do
  x
end
 
l2 = nil
class X;end
X.class_eval do
  l2 = lambda do
    x
  end
end
 
t1 = Benchmark.realtime do
  100000.times { Module.mix_eval(m, &l) }
  100000.times { Module.mix_eval(m, &l2) }
end
 
t2 = Benchmark.realtime do
  100000.times { Module.safe_mix_eval(m, &l) }
  100000.times { Module.safe_mix_eval(m, &l2) }
end
 
p :orig, t1, :safe, t2