Pastie now auto-senses if line-wrap is a bad or good idea. Feedback?
## mark a section (Learn more)
This paste will be private.
## benchmark 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 ## MRI 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) ## before stat and Float 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) ## after fixes euler:rubinius brian$ TOTAL=10 shotgun/rubinius glob.rb Rehearsal ----------------------------------------- loop 0.000603 0.000000 0.000603 ( 0.000618) Dir[] 44.284485 0.000000 44.284485 ( 44.284487) ------------------------------- total: 44.285088sec user system total real loop 0.000650 0.000000 0.000650 ( 0.000671) Dir[] 44.153387 0.000000 44.153387 ( 44.153395) ## after rewrite of File.fnmatch to not use Regexp Rehearsal ----------------------------------------- loop 0.000563 0.000000 0.000563 ( 0.000565) Dir[] 7.343731 0.000000 7.343731 ( 7.343732) -------------------------------- total: 7.344294sec user system total real loop 0.000589 0.000000 0.000589 ( 0.000615) Dir[] 7.313950 0.000000 7.313950 ( 7.313972)
From the Design Piracy series on my blog: