Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Use autoload to delay loading features until we need them.
This yields about a 10% improvement in the time it takes to initially load rspec-mocks.
- Loading branch information
1 parent
5fe844e
commit 47d398b
Showing
7 changed files
with
76 additions
and
35 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,31 @@ | |||
time (for i in {1..100}; do ruby -Ilib:../rspec-support/lib -rrspec/mocks -e ""; done) | |||
|
|||
# 3 runs before our autoload changes | |||
# real 0m4.497s | |||
# user 0m3.662s | |||
# sys 0m0.677s | |||
# | |||
# real 0m4.472s | |||
# user 0m3.644s | |||
# sys 0m0.671s | |||
# | |||
# real 0m4.465s | |||
# user 0m3.640s | |||
# sys 0m0.668s | |||
|
|||
# 3 runs after our autoload changes: | |||
# | |||
# real 0m4.038s | |||
# user 0m3.274s | |||
# sys 0m0.609s | |||
# | |||
# real 0m4.038s | |||
# user 0m3.274s | |||
# sys 0m0.609s | |||
# | |||
# real 0m4.038s | |||
# user 0m3.274s | |||
# sys 0m0.609s | |||
|
|||
# It's modest, but that's about a 10% improvement: an average | |||
# of about 40ms to load rather than 45 ms to load. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,7 @@ | |||
require 'rspec/mocks/any_instance/chain' | |||
require 'rspec/mocks/any_instance/stub_chain' | |||
require 'rspec/mocks/any_instance/stub_chain_chain' | |||
require 'rspec/mocks/any_instance/expect_chain_chain' | |||
require 'rspec/mocks/any_instance/expectation_chain' | |||
require 'rspec/mocks/any_instance/message_chains' | |||
require 'rspec/mocks/any_instance/recorder' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,20 @@ | |||
module RSpec | |||
module Mocks | |||
module Matchers | |||
# @private | |||
class ExpectationCustomization | |||
attr_accessor :block | |||
|
|||
def initialize(method_name, args, block) | |||
@method_name = method_name | |||
@args = args | |||
@block = block | |||
end | |||
|
|||
def playback_onto(expectation) | |||
expectation.__send__(@method_name, *@args, &@block) | |||
end | |||
end | |||
end | |||
end | |||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters