Created
September 13, 2011 05:20
-
-
Save mipearson/1213178 to your computer and use it in GitHub Desktop.
File.exist? benchmark of existing / non existing file
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
ubuntu@localtest:~$ cat stat.rb | |
require 'benchmark' | |
puts Benchmark.measure { | |
1000000.times do | |
File.exist?(ARGV[0]) | |
end | |
} | |
ubuntu@localtest:~$ ls -l foo | |
ls: cannot access foo: No such file or directory | |
ubuntu@localtest:~$ ruby stat.rb foo | |
0.570000 0.310000 0.880000 ( 0.876064) | |
ubuntu@localtest:~$ ruby stat.rb stat.rb | |
0.560000 0.390000 0.950000 ( 0.952491) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment