require'benchmark'
total = (ENV['TOTAL']||1_000).to_iBenchmark.bmbmdo |x|
x.report("loop") do
times =0while times < total
Dir['']
times +=1endend
x.report("Dir[]") do
times =0while times < total
Dir["spec/**/*_spec.rb"]
times +=1endendend
ruby
1
2
3
4
5
6
7
8
9
10
euler:rubinius brian$ TOTAL=10 ruby glob.rbRehearsal-----------------------------------------loop0.0000000.0000000.000000 ( 0.000029)
Dir[] 0.1000000.3000000.400000 ( 0.412668)
-------------------------------- total: 0.400000sec
user system total real
loop0.0000000.0000000.000000 ( 0.000017)
Dir[] 0.1000000.3100000.410000 ( 0.431814)
rbx before stat fixes
1
2
3
4
5
6
7
8
9
10
euler:rubinius brian$ TOTAL=10 shotgun/rubinius glob.rbRehearsal-----------------------------------------loop0.0008210.0000000.000821 ( 0.000830)
Dir[] 95.1120580.00000095.112058 ( 95.112051)
------------------------------- total: 95.112879sec
user system total real
loop0.0041520.0000000.004152 ( 0.004164)
Dir[] 95.6482900.00000095.648290 ( 95.648307)