Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- require 'benchmark'
- # Benchmarks for various File operations.
- #
- # user system total real
- # expand_path . 0.050000 0.120000 0.170000 ( 0.183515)
- # expand_path ./../dir 0.040000 0.110000 0.150000 ( 0.160149)
- # expand_path ~ 0.010000 0.000000 0.010000 ( 0.008848)
- # expand_path ~/../dir 0.010000 0.000000 0.010000 ( 0.009907)
- # expand_path / 0.010000 0.000000 0.010000 ( 0.009150)
- # expand_path /path/to/dir 0.010000 0.000000 0.010000 ( 0.009634)
- #
- Benchmark.bm(25) do |x|
- n = 10000
- x.report "expand_path ." do
- n.times { File.expand_path(".") }
- end
- x.report "expand_path ./../dir" do
- n.times { File.expand_path("./../dir") }
- end
- x.report "expand_path ~" do
- n.times { File.expand_path("~") }
- end
- x.report "expand_path ~/../dir" do
- n.times { File.expand_path("~/../dir") }
- end
- x.report "expand_path /" do
- n.times { File.expand_path("/") }
- end
- x.report "expand_path /path/to/dir" do
- n.times { File.expand_path("/path/to/dir") }
- end
- end
Add Comment
Please, Sign In to add comment