This repository has been archived by the owner on Nov 30, 2024. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 759
Benchmark require relative and update to new rspec-support method #1348
Merged
Merged
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
af5f60a
Benchmark require_relative.
myronmarston 78daad6
But wait...using this old benchmark it does make a difference?
myronmarston 950f6db
Benchmark the perf difference with a load path of different sizes.
myronmarston 49a708b
Use new rspec-support requires.
myronmarston 322d272
Move `set` require to file where it is used.
myronmarston b088f95
One line per require file.
myronmarston 6c4ecea
Remove benchmark file.
myronmarston File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,123 @@ | ||
ruby -v | ||
|
||
function run_benchmark_with_load_path_size { | ||
pushd tmp | ||
mkdir -p boot_time_benchmark | ||
|
||
local load_path_size=$1 | ||
for (( i=0; i < $load_path_size; i++ )); do | ||
mkdir -p "boot_time_benchmark/dir_$i" | ||
done | ||
|
||
local load_path=`ruby -e 'puts Array.new(Integer(ARGV.first)) { |i| "boot_time_benchmark/dir_#{i}" }.join(":")' $load_path_size` | ||
|
||
echo "3 runs with $load_path_size dirs on load path, booting 50 times, using $2" | ||
for i in {1..3}; do | ||
time (for i in {1..50}; do ruby -I$load_path:../lib:../../rspec-support/lib -e 'require "rspec/core"'; done) | ||
done | ||
popd | ||
} | ||
|
||
run_benchmark_with_load_path_size 10 "require" | ||
run_benchmark_with_load_path_size 100 "require" | ||
run_benchmark_with_load_path_size 1000 "require" | ||
|
||
export REQUIRE_RELATIVE=1 | ||
|
||
run_benchmark_with_load_path_size 10 "require_relative" | ||
run_benchmark_with_load_path_size 100 "require_relative" | ||
run_benchmark_with_load_path_size 1000 "require_relative" | ||
|
||
: <<'result_comment' | ||
ruby 2.0.0p247 (2013-06-27 revision 41674) [x86_64-darwin12.4.0] | ||
~/code/rspec-core/tmp ~/code/rspec-core | ||
3 runs with 10 dirs on load path, booting 50 times, using require | ||
|
||
real 0m3.815s | ||
user 0m3.205s | ||
sys 0m0.519s | ||
|
||
real 0m3.850s | ||
user 0m3.234s | ||
sys 0m0.527s | ||
|
||
real 0m3.840s | ||
user 0m3.225s | ||
sys 0m0.525s | ||
~/code/rspec-core | ||
~/code/rspec-core/tmp ~/code/rspec-core | ||
3 runs with 100 dirs on load path, booting 50 times, using require | ||
|
||
real 0m5.086s | ||
user 0m3.887s | ||
sys 0m1.107s | ||
|
||
real 0m5.063s | ||
user 0m3.870s | ||
sys 0m1.098s | ||
|
||
real 0m5.061s | ||
user 0m3.871s | ||
sys 0m1.097s | ||
~/code/rspec-core | ||
~/code/rspec-core/tmp ~/code/rspec-core | ||
3 runs with 1000 dirs on load path, booting 50 times, using require | ||
|
||
real 0m18.850s | ||
user 0m11.057s | ||
sys 0m7.679s | ||
|
||
real 0m18.783s | ||
user 0m11.012s | ||
sys 0m7.657s | ||
|
||
real 0m18.747s | ||
user 0m10.992s | ||
sys 0m7.639s | ||
~/code/rspec-core | ||
~/code/rspec-core/tmp ~/code/rspec-core | ||
3 runs with 10 dirs on load path, booting 50 times, using require_relative | ||
|
||
real 0m3.794s | ||
user 0m3.200s | ||
sys 0m0.506s | ||
|
||
real 0m3.769s | ||
user 0m3.180s | ||
sys 0m0.502s | ||
|
||
real 0m3.787s | ||
user 0m3.192s | ||
sys 0m0.502s | ||
~/code/rspec-core | ||
~/code/rspec-core/tmp ~/code/rspec-core | ||
3 runs with 100 dirs on load path, booting 50 times, using require_relative | ||
|
||
real 0m4.626s | ||
user 0m3.620s | ||
sys 0m0.910s | ||
|
||
real 0m4.652s | ||
user 0m3.642s | ||
sys 0m0.915s | ||
|
||
real 0m4.678s | ||
user 0m3.662s | ||
sys 0m0.924s | ||
~/code/rspec-core | ||
~/code/rspec-core/tmp ~/code/rspec-core | ||
3 runs with 1000 dirs on load path, booting 50 times, using require_relative | ||
|
||
real 0m14.400s | ||
user 0m8.615s | ||
sys 0m5.675s | ||
|
||
real 0m14.495s | ||
user 0m8.672s | ||
sys 0m5.711s | ||
|
||
real 0m14.541s | ||
user 0m8.705s | ||
sys 0m5.727s | ||
~/code/rspec-core | ||
result_comment |
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
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 | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,6 @@ | ||
require 'erb' | ||
require 'shellwords' | ||
require 'set' | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. An aside, are we not worried about polluting stdlib here? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This isn't a new require; see 322d272. We prefer not to pollute stdlib, but it's not an absolute rule. |
||
|
||
module RSpec | ||
module Core | ||
|
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
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
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
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
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
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I sorta miss the line-per-require format - it allowed for groupings and it was easier to read even though it was repetitive.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ya, think I agree...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I initially had that, but we had more duplicated on each line (the
RSpec::Support.require_rspec_core
bit) than was different on each line (the file name). So I collapsed it.What do you think about keeping the
array.each
but putting each file on its own line (with optional blank lines in there for grouping)?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sounds fair to me.
The require method could also take varargs so that
RSpec::Support.require_rspec_core
is up-front instead of trailing the array… but I don't have strong feelings about that TBH.