require 'benchmark'
total = (ENV['TOTAL'] || 1_000).to_i
Benchmark.bmbm do |x|
x.report("loop") do
times = 0
while times < total
Dir['']
times += 1
end
end
x.report("Dir[]") do
times = 0
while times < total
Dir["spec/**/*_spec.rb"]
times += 1
end
end
end
ruby
euler:rubinius brian$ TOTAL=10 ruby glob.rb
Rehearsal -----------------------------------------
loop 0.000000 0.000000 0.000000 ( 0.000029)
Dir[] 0.100000 0.300000 0.400000 ( 0.412668)
-------------------------------- total: 0.400000sec
user system total real
loop 0.000000 0.000000 0.000000 ( 0.000017)
Dir[] 0.100000 0.310000 0.410000 ( 0.431814)
rbx before stat fixes
euler:rubinius brian$ TOTAL=10 shotgun/rubinius glob.rb
Rehearsal -----------------------------------------
loop 0.000821 0.000000 0.000821 ( 0.000830)
Dir[] 95.112058 0.000000 95.112058 ( 95.112051)
------------------------------- total: 95.112879sec
user system total real
loop 0.004152 0.000000 0.004152 ( 0.004164)
Dir[] 95.648290 0.000000 95.648290 ( 95.648307)