File: native-vs-pathutil-relative

package info (click to toggle)
jekyll 4.3.4%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 6,356 kB
  • sloc: ruby: 16,765; javascript: 1,455; sh: 214; xml: 29; makefile: 9
file content (33 lines) | stat: -rwxr-xr-x 830 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
#!/usr/bin/env ruby

# -------------------------------------------------------------------
# Benchmarking changes in https://github.com/jekyll/jekyll/pull/6767
# -------------------------------------------------------------------

require 'benchmark/ips'
require 'pathutil'

DOC_PATH = File.join(File.expand_path(__dir__), "_puppies", "rover.md")
COL_PATH = File.join(File.expand_path(__dir__), "_puppies")


def pathutil_relative
  Pathutil.new(DOC_PATH).relative_path_from(COL_PATH).to_s
end

def native_relative
  DOC_PATH.sub("#{COL_PATH}/", "")
end

if pathutil_relative == native_relative
  Benchmark.ips do |x|
    x.report("pathutil") { pathutil_relative }
    x.report("native")   { native_relative }
    x.compare!
  end
else
  print "PATHUTIL: "
  puts pathutil_relative
  print "NATIVE:   "
  puts native_relative
end