Skip to content

Instantly share code, notes, and snippets.

@xaviershay
Created May 22, 2011 06:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save xaviershay/985224 to your computer and use it in GitHub Desktop.
Save xaviershay/985224 to your computer and use it in GitHub Desktop.
Benchmark for ruby require performance with LOAD_PATH
$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
`mkdir f`
10000.times do |x|
`touch f/bogus#{x}.rb`
end
@xaviershay
Copy link
Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment