Guest User

Untitled

a guest
Apr 25th, 2018
66
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.10 KB | None | 0 0
  1. require 'benchmark'
  2.  
  3. # Benchmarks for various File operations.
  4. #
  5. # user system total real
  6. # expand_path . 0.050000 0.120000 0.170000 ( 0.183515)
  7. # expand_path ./../dir 0.040000 0.110000 0.150000 ( 0.160149)
  8. # expand_path ~ 0.010000 0.000000 0.010000 ( 0.008848)
  9. # expand_path ~/../dir 0.010000 0.000000 0.010000 ( 0.009907)
  10. # expand_path / 0.010000 0.000000 0.010000 ( 0.009150)
  11. # expand_path /path/to/dir 0.010000 0.000000 0.010000 ( 0.009634)
  12. #
  13. Benchmark.bm(25) do |x|
  14.  
  15. n = 10000
  16.  
  17. x.report "expand_path ." do
  18. n.times { File.expand_path(".") }
  19. end
  20.  
  21. x.report "expand_path ./../dir" do
  22. n.times { File.expand_path("./../dir") }
  23. end
  24.  
  25. x.report "expand_path ~" do
  26. n.times { File.expand_path("~") }
  27. end
  28.  
  29. x.report "expand_path ~/../dir" do
  30. n.times { File.expand_path("~/../dir") }
  31. end
  32.  
  33. x.report "expand_path /" do
  34. n.times { File.expand_path("/") }
  35. end
  36.  
  37. x.report "expand_path /path/to/dir" do
  38. n.times { File.expand_path("/path/to/dir") }
  39. end
  40. end
Add Comment
Please, Sign In to add comment