Created
May 22, 2011 06:26
-
-
Save xaviershay/985224 to your computer and use it in GitHub Desktop.
Benchmark for ruby require performance with LOAD_PATH
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
$LOAD_PATH.unshift(File.expand_path('f')) | |
x = 0 | |
y = 0 | |
require 'benchmark' | |
Benchmark.bm do |b| | |
step = 500 | |
(0..4).each do |n| | |
b.report("#{n * step} in load path") { 50.times { require "bogus#{x}"; x += 1 }} | |
step.times do | |
$LOAD_PATH.unshift("/tmp/folder#{y}") | |
y += 1 | |
end | |
$LOADED_FEATURES.clear | |
$stdout.flush | |
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
`mkdir f` | |
10000.times do |x| | |
`touch f/bogus#{x}.rb` | |
end |
Author
xaviershay
commented
May 22, 2011
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment