Skip to content

Instantly share code, notes, and snippets.

@kuldeepaggarwal
Created November 19, 2013 13:53
Show Gist options
  • Save kuldeepaggarwal/7545688 to your computer and use it in GitHub Desktop.
Save kuldeepaggarwal/7545688 to your computer and use it in GitHub Desktop.
require 'benchmark'
TIMES = 500
Benchmark.bm { |p|
p.report("new") do
TIMES.times do
Dir[(`pwd`).chomp + '/**/*.rb'].map! { |e| e }.sort!
end
end
p.report("old") do
TIMES.times do
names = Dir[(`pwd`).chomp + '/**/*.rb'].map { |e| e }
names.sort!
end
end
};
user system total real
new 0.330000 1.010000 2.510000 ( 2.747355)
old 0.350000 1.030000 2.580000 ( 2.809858)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment