Improve performance of double creation.
Created by: xaviershay
A couple of optimisations that speed up double creation significantly. See individual commits for their contribution details.
Time to create 1000 doubles:
I just cranked away with benchmark and ruby-prof
for a while, using code like the following:
n = 1000
Benchmark.bm do |bm|
RSpec::Mocks.setup(self)
(0..9).each do |m|
attrs = m.times.inject({}) {|h, x|
h["method_#{x}"] = x
h
}
bm.report("double") do
n.times do
double(attrs)
end
end
end
end
Notes
-
caller
location has changed forexpected_from
definition. Pretty sure this isn't a problem. - "simple stub" is a new concept, I believe it justifies itself in the speed improvement.
- Addresses #193 (closed).
R @myronmarston