Sha256: 7a73a449c55ddbe4ec08e2522f29f52a7e82d79aaa8850bdf3e6bbca4d1c88b1

Contents?: true

Size: 1.56 KB

Versions: 26

Compression:

Stored size: 1.56 KB

Contents

#!/usr/bin/env ruby
# frozen_string_literal: true

require_relative '../lib/jekyll'
require 'benchmark/ips'

base_directory = Dir.pwd

Benchmark.ips do |x|
  #
  # Does not include the base_directory
  #
  x.report('with no questionable path') do
    Jekyll.sanitized_path(base_directory, '')
  end
  x.report('with a single-part questionable path') do
    Jekyll.sanitized_path(base_directory, 'thingy')
  end
  x.report('with a multi-part questionable path') do
    Jekyll.sanitized_path(base_directory, 'thingy/in/my/soup')
  end
  x.report('with a single-part traversal path') do
    Jekyll.sanitized_path(base_directory, '../thingy')
  end
  x.report('with a multi-part traversal path') do
    Jekyll.sanitized_path(base_directory, '../thingy/in/my/../../soup')
  end

  #
  # Including the base_directory
  #
  x.report('with the exact same paths') do
    Jekyll.sanitized_path(base_directory, base_directory)
  end
  x.report('with a single-part absolute path including the base_directory') do
    Jekyll.sanitized_path(base_directory, File.join(base_directory, 'thingy'))
  end
  x.report('with a multi-part absolute path including the base_directory') do
    Jekyll.sanitized_path(base_directory, File.join(base_directory, 'thingy/in/my/soup'))
  end
  x.report('with a single-part traversal path including the base_directory') do
    Jekyll.sanitized_path(base_directory, File.join(base_directory, 'thingy/..'))
  end
  x.report('with a multi-part traversal path including the base_directory') do
    Jekyll.sanitized_path(base_directory, File.join('thingy/in/my/../../soup'))
  end
end

Version data entries

26 entries across 26 versions & 1 rubygems

Version Path
lbenicio-minimal-v1-1.6.4 benchmark/jekyll-sanitize-path
lbenicio-minimal-v1-1.6.3 benchmark/jekyll-sanitize-path
lbenicio-minimal-v1-1.6.2 benchmark/jekyll-sanitize-path
lbenicio-minimal-v1-1.6.1 benchmark/jekyll-sanitize-path
lbenicio-minimal-v1-1.5.3 benchmark/jekyll-sanitize-path
lbenicio-minimal-v1-1.5.2 benchmark/jekyll-sanitize-path
lbenicio-minimal-v1-1.5.0 benchmark/jekyll-sanitize-path
lbenicio-minimal-v1-1.4.0 benchmark/jekyll-sanitize-path
lbenicio-minimal-v1-1.3.3 benchmark/jekyll-sanitize-path
lbenicio-minimal-v1-1.3.2 benchmark/jekyll-sanitize-path
lbenicio-minimal-v1-1.3.1 benchmark/jekyll-sanitize-path
lbenicio-minimal-v1-1.3.0 benchmark/jekyll-sanitize-path
lbenicio-minimal-v1-1.2.1 benchmark/jekyll-sanitize-path
lbenicio-minimal-v1-1.2.0 benchmark/jekyll-sanitize-path
lbenicio-minimal-v1-1.1.9 benchmark/jekyll-sanitize-path
lbenicio-minimal-v1-1.1.8 benchmark/jekyll-sanitize-path
lbenicio-minimal-v1-1.1.7 benchmark/jekyll-sanitize-path
lbenicio-minimal-v1-1.1.6 benchmark/jekyll-sanitize-path
lbenicio-minimal-v1-1.1.5 benchmark/jekyll-sanitize-path
lbenicio-minimal-v1-1.1.4 benchmark/jekyll-sanitize-path