Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
122 additions
and
14 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,12 @@ | ||
require "benchmark" | ||
|
||
STR1 = "Hello" | ||
JOIN = "::" | ||
STR2 = "World" | ||
|
||
TESTS = 100_000 | ||
Benchmark.bmbm do |results| | ||
results.report("concat") { TESTS.times { "".concat(STR1).concat(JOIN).concat(STR2) } } | ||
results.report("add ") { TESTS.times { STR1 + JOIN + STR2 } } | ||
results.report("join ") { TESTS.times { [STR1, STR2].join(JOIN) } } | ||
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
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,50 @@ | ||
require 'pathname' | ||
require "benchmark" | ||
require File.dirname(__FILE__) + '/../lib/yard' | ||
|
||
pathobj = Pathname.new("a/b/c") | ||
strobj = "a/b/c" | ||
|
||
TIMES = 1_000 | ||
|
||
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 | ||
|
||
puts | ||
puts | ||
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) |
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,22 @@ | ||
require "benchmark" | ||
require File.join(File.dirname(__FILE__), '..', 'lib', 'yard') | ||
|
||
YARD::Registry.load_yardoc(File.join(File.dirname(__FILE__), '..', '.yardoc')) | ||
obj = YARD::Registry.at("YARD::CodeObjects::Base") | ||
|
||
TIMES = 3 | ||
Benchmark.bm do |x| | ||
x.report("trim-line") { TIMES.times { obj.format(:format => :html) } } | ||
module YARD | ||
module Templates | ||
module Template | ||
def erb(section, &block) | ||
erb = ERB.new(cache(section), nil) | ||
erb.filename = cache_filename(section).to_s | ||
erb.result(binding, &block) | ||
end | ||
end | ||
end | ||
end | ||
x.report("no-trim ") { TIMES.times { obj.format(:format => :html) } } | ||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
require "benchmark" | ||
require File.join(File.dirname(__FILE__), '..', 'lib', 'yard') | ||
|
||
YARD::Registry.load_yardoc(File.join(File.dirname(__FILE__), '..', '.yardoc')) | ||
obj = YARD::Registry.at("YARD::CodeObjects::Base") | ||
puts Benchmark.measure { obj.format(:format => :html) } |
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,18 @@ | ||
require 'rubygems' | ||
#require 'ruby-prof' | ||
#require 'benchmark' | ||
require File.join(File.dirname(__FILE__), '..', 'lib', 'yard') | ||
|
||
YARD::Registry.load_yardoc(File.join(File.dirname(__FILE__), '..', '.yardoc')) | ||
obj = YARD::Registry.at("YARD::CodeObjects::Base") | ||
|
||
require 'perftools' | ||
PerfTools::CpuProfiler.start("template_profile") do | ||
obj.format(:format => :html, :no_highlight => true) | ||
end | ||
|
||
# result = RubyProf.profile do | ||
# end | ||
# | ||
# printer = RubyProf::CallTreePrinter.new(result) | ||
# printer.print(STDOUT) |