File: bench_pathname.rb

package info (click to toggle)
ruby-facets 2.9.2-1
  • links: PTS, VCS
  • area: main
  • in suites: wheezy
  • size: 9,824 kB
  • sloc: ruby: 25,483; xml: 90; makefile: 20
file content (24 lines) | stat: -rw-r--r-- 406 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24

  require 'benchmark'
  #require 'pathname'
  require 'mega/pathname'

  $f1 = "a/b/c"
  $f2 = "d/e/f"

  $p1 = Pathname.new($f1)
  $p2 = Pathname.new($f2)

  def file_join
    File.join( $f1 , $f2 )
  end

  def path_join
    $p1 + $p2
  end

  n = 50000
  Benchmark.bm(7) do |x|
    x.report("path-join") { n.times do ; path_join ; end }
    x.report("file-join") { n.times do ; file_join ; end }
  end