Sha256: 163222e42a39720a9b69f71d6986c5aff06b96daa410af3b20fca6c99e4b7fef

Contents?: true

Size: 1.22 KB

Versions: 54

Compression:

Stored size: 1.22 KB

Contents

require "benchmark"
require 'lib/yard'

def format_args_regex(object)
  if object.signature
    object.signature[/#{Regexp.quote object.name.to_s}\s*(.*)/, 1]
  else
    ""
  end
end

def format_args_parameters(object)
  if !object.parameters.empty?
    args = object.parameters.map {|n, v| v ? "#{n} = #{v}" : n.to_s }.join(", ")
    "(#{args})"
  else
    ""
  end
end

YARD::Registry.load
$object = YARD::Registry.at('YARD::Generators::Base#G')

log.puts "regex:  " + format_args_regex($object)
log.puts "params: " + format_args_parameters($object)
log.puts

TIMES = 100_000
Benchmark.bmbm do |x|
  x.report("regex")      { TIMES.times { format_args_regex($object) } }
  x.report("parameters") { TIMES.times { format_args_parameters($object) } }
end

=begin LAST RUN Jun 23 2008
regex:  (generator, opts = {})
params: (generator, opts = {})

Rehearsal ----------------------------------------------
regex        1.270000   0.020000   1.290000 (  1.294558)
parameters   0.690000   0.000000   0.690000 (  0.693324)
------------------------------------- total: 1.980000sec

                 user     system      total        real
regex        1.260000   0.010000   1.270000 (  1.268214)
parameters   0.670000   0.000000   0.670000 (  0.679114)
=end

Version data entries

54 entries across 45 versions & 8 rubygems

Version Path
abaci-0.3.0 vendor/bundle/gems/yard-0.9.1/benchmarks/format_args.rb
abaci-0.3.0 vendor/bundle/gems/yard-0.9.2/benchmarks/format_args.rb
yard-0.9.5 benchmarks/format_args.rb
yard-0.9.4 benchmarks/format_args.rb
yard-0.9.3 benchmarks/format_args.rb
yard-0.9.2 benchmarks/format_args.rb
yard-0.9.1 benchmarks/format_args.rb
yard-0.9.0 benchmarks/format_args.rb
yard-0.8.7.6 benchmarks/format_args.rb
yard-0.8.7.5 benchmarks/format_args.rb
climine-0.0.7 vendor/bundle/ruby/2.1.0/gems/yard-0.8.7.3/benchmarks/format_args.rb
climine-0.0.7 vendor/bundle/ruby/2.0.0/gems/yard-0.8.7.3/benchmarks/format_args.rb
climine-0.0.6 vendor/bundle/ruby/2.0.0/gems/yard-0.8.7.3/benchmarks/format_args.rb
climine-0.0.5 vendor/bundle/ruby/2.0.0/gems/yard-0.8.7.3/benchmarks/format_args.rb
yard-0.8.7.4 benchmarks/format_args.rb
climine-0.0.4 vendor/bundle/ruby/2.0.0/gems/yard-0.8.7.3/benchmarks/format_args.rb
climine-0.0.3 vendor/bundle/ruby/2.0.0/gems/yard-0.8.7.3/benchmarks/format_args.rb
mango-0.8.0 vendor/bundler/ruby/2.1.0/gems/yard-0.8.7.3/benchmarks/format_args.rb
mango-0.7.1 vendor/bundler/ruby/2.0.0/gems/yard-0.8.7.3/benchmarks/format_args.rb
mango-0.7.0 vendor/bundler/ruby/2.0.0/gems/yard-0.8.7.3/benchmarks/format_args.rb