Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 50 lines (41 sloc) 1.887 kb
b0d6729 @lsegal Add/update benchmarks for templates
authored
1 require 'pathname'
2 require "benchmark"
3 require File.dirname(__FILE__) + '/../lib/yard'
4
5 pathobj = Pathname.new("a/b/c")
6 strobj = "a/b/c"
7
8 TIMES = 1_000
9
d756bdb @lsegal Centralize all printing through Logger so progress indicator can be prop...
authored
10 log.puts "join:"
b0d6729 @lsegal Add/update benchmarks for templates
authored
11 Benchmark.bmbm do |x|
12 x.report("pathname") { TIMES.times { Pathname.new("a/b/c").join("d", "e", "f") } }
13 x.report("string ") { TIMES.times { File.join("a/b/c", "d", "e", "f") } }
14 x.report("pathname-sameobject") { TIMES.times { pathobj.join("d", "e", "f") } }
15 x.report("string-sameobject ") { TIMES.times { File.join(strobj, "d", "e", "f") } }
16 end
17
d756bdb @lsegal Centralize all printing through Logger so progress indicator can be prop...
authored
18 log.puts
19 log.puts
20 log.puts "cleanpath:"
b0d6729 @lsegal Add/update benchmarks for templates
authored
21 Benchmark.bmbm do |x|
22 x.report("pathname") { TIMES.times { Pathname.new("a/b//.././c").cleanpath } }
23 x.report("string ") { TIMES.times { File.cleanpath("a/b//.././c") } }
24 end
25
26 __END__
27 join:
28 Rehearsal -------------------------------------------------------
29 pathname 0.330000 0.020000 0.350000 ( 0.353481)
30 string 0.010000 0.000000 0.010000 ( 0.001390)
31 pathname-sameobject 0.360000 0.020000 0.380000 ( 0.384473)
32 string-sameobject 0.000000 0.000000 0.000000 ( 0.001187)
33 ---------------------------------------------- total: 0.740000sec
34
35 user system total real
36 pathname 0.330000 0.020000 0.350000 ( 0.350820)
37 string 0.000000 0.000000 0.000000 ( 0.001055)
38 pathname-sameobject 0.330000 0.010000 0.340000 ( 0.346949)
39 string-sameobject 0.000000 0.000000 0.000000 ( 0.001141)
40
41
42 cleanpath:
43 Rehearsal --------------------------------------------
44 pathname 0.060000 0.000000 0.060000 ( 0.059767)
45 string 0.010000 0.000000 0.010000 ( 0.013775)
46 ----------------------------------- total: 0.070000sec
47
48 user system total real
49 pathname 0.060000 0.000000 0.060000 ( 0.059697)
50 string 0.020000 0.000000 0.020000 ( 0.013624)
Something went wrong with that request. Please try again.