forked from jekyll/jekyll
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Compute document's relative_path faster (jekyll#6767)
Merge pull request 6767
- Loading branch information
Showing
2 changed files
with
34 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters