On 10/25/05, Berger, Daniel <Daniel.Berger / qwest.com> wrote:
> Do you have an example you can share where its performance was poor?
require 'benchmark'
require '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
user system total real
path-join 0.990000 0.040000 1.030000 ( 1.128913)
file-join 0.190000 0.010000 0.200000 ( 0.224484)