Sha256: 7c9086f513e31b62ce0e2ae4da7a2b4820ffdff8326292a178acaf0e01ea888e

Contents?: true

Size: 1.87 KB

Versions: 43

Compression:

Stored size: 1.87 KB

Contents

# frozen_string_literal: true
require 'pathname'
require "benchmark"
require File.dirname(__FILE__) + '/../lib/yard'

pathobj = Pathname.new("a/b/c")
strobj  = "a/b/c"

TIMES = 1_000

log.puts "join:"
Benchmark.bmbm do |x|
  x.report("pathname") { TIMES.times { Pathname.new("a/b/c").join("d", "e", "f") } }
  x.report("string  ") { TIMES.times { File.join("a/b/c", "d", "e", "f") } }
  x.report("pathname-sameobject") { TIMES.times { pathobj.join("d", "e", "f") } }
  x.report("string-sameobject  ") { TIMES.times { File.join(strobj, "d", "e", "f") } }
end

log.puts
log.puts
log.puts "cleanpath:"
Benchmark.bmbm do |x|
  x.report("pathname") { TIMES.times { Pathname.new("a/b//.././c").cleanpath } }
  x.report("string  ") { TIMES.times { File.cleanpath("a/b//.././c") } }
end

__END__
join:
Rehearsal -------------------------------------------------------
pathname              0.330000   0.020000   0.350000 (  0.353481)
string                0.010000   0.000000   0.010000 (  0.001390)
pathname-sameobject   0.360000   0.020000   0.380000 (  0.384473)
string-sameobject     0.000000   0.000000   0.000000 (  0.001187)
---------------------------------------------- total: 0.740000sec

                          user     system      total        real
pathname              0.330000   0.020000   0.350000 (  0.350820)
string                0.000000   0.000000   0.000000 (  0.001055)
pathname-sameobject   0.330000   0.010000   0.340000 (  0.346949)
string-sameobject     0.000000   0.000000   0.000000 (  0.001141)


cleanpath:
Rehearsal --------------------------------------------
pathname   0.060000   0.000000   0.060000 (  0.059767)
string     0.010000   0.000000   0.010000 (  0.013775)
----------------------------------- total: 0.070000sec

               user     system      total        real
pathname   0.060000   0.000000   0.060000 (  0.059697)
string     0.020000   0.000000   0.020000 (  0.013624)

Version data entries

43 entries across 42 versions & 7 rubygems

Version Path
kinetic_sdk-5.0.25 gems/yard-0.9.25/benchmarks/pathname_vs_string.rb
kinetic_sdk-5.0.24 gems/yard-0.9.25/benchmarks/pathname_vs_string.rb
kinetic_sdk-5.0.23 gems/yard-0.9.25/benchmarks/pathname_vs_string.rb
kinetic_sdk-5.0.22 gems/yard-0.9.25/benchmarks/pathname_vs_string.rb
kinetic_sdk-5.0.21 gems/yard-0.9.25/benchmarks/pathname_vs_string.rb
devcycle-ruby-server-sdk-2.0.0 vendor/bundle/ruby/3.0.0/gems/yard-0.9.28/benchmarks/pathname_vs_string.rb
kinetic_sdk-5.0.20 gems/yard-0.9.25/benchmarks/pathname_vs_string.rb
yard-0.9.28 benchmarks/pathname_vs_string.rb
yard-0.9.27 benchmarks/pathname_vs_string.rb
yard-0.9.26 benchmarks/pathname_vs_string.rb
qiita_org-0.1.35 gems/ruby/2.7.0/gems/yard-0.9.25/benchmarks/pathname_vs_string.rb
qiita_org-0.1.34 gems/ruby/2.7.0/gems/yard-0.9.25/benchmarks/pathname_vs_string.rb
qiita_org-0.1.33 gems/ruby/2.7.0/gems/yard-0.9.25/benchmarks/pathname_vs_string.rb
qiita_org-0.1.32 gems/ruby/2.7.0/gems/yard-0.9.25/benchmarks/pathname_vs_string.rb
qiita_org-0.1.31 gems/ruby/2.7.0/gems/yard-0.9.25/benchmarks/pathname_vs_string.rb
qiita_org-0.1.30 gems/ruby/2.7.0/gems/yard-0.9.25/benchmarks/pathname_vs_string.rb
qiita_org-0.1.29 gems/ruby/2.7.0/gems/yard-0.9.25/benchmarks/pathname_vs_string.rb
qiita_org-0.1.28 gems/ruby/2.7.0/gems/yard-0.9.25/benchmarks/pathname_vs_string.rb
qiita_org-0.1.27 gems/ruby/2.7.0/gems/yard-0.9.25/benchmarks/pathname_vs_string.rb
qiita_org-0.1.26 gems/ruby/2.7.0/gems/yard-0.9.25/benchmarks/pathname_vs_string.rb