Sha256: eb963eedad804b51228196f66b49834d209e0c756226b66b926d7aa525865f0c

Contents?: true

Size: 949 Bytes

Versions: 56

Compression:

Stored size: 949 Bytes

Contents

require 'benchmark'
require File.join(File.dirname(__FILE__), '..', 'lib', 'yard')

TIMES = (ARGV[0] || 10_000).to_i

def bench_builtins(name)
  YARD::CodeObjects::BUILTIN_EXCEPTIONS_HASH.has_key? name
end

def bench_eval(name)
  eval(name).is_a?(Class)
rescue 
  false
end

Benchmark.bmbm do |b|
  b.report("builtins PASS") { TIMES.times {YARD::CodeObjects::BUILTIN_EXCEPTIONS.each {|y| bench_builtins(y) } } }
  b.report("eval PASS") { TIMES.times {YARD::CodeObjects::BUILTIN_EXCEPTIONS.each {|y| bench_eval(y) }} }
  b.report("builtins FAIL") { TIMES.times {YARD::CodeObjects::BUILTIN_MODULES.each {|y| bench_builtins(y) } } }
  b.report("eval FAIL") { TIMES.times {YARD::CodeObjects::BUILTIN_MODULES.each {|y| bench_eval(y) }} }
  b.report("builtins ANY") { TIMES.times {YARD::CodeObjects::BUILTIN_CLASSES.each {|y| bench_builtins(y) } } }
  b.report("eval ANY") { TIMES.times {YARD::CodeObjects::BUILTIN_CLASSES.each {|y| bench_eval(y) }} }
end

Version data entries

56 entries across 56 versions & 4 rubygems

Version Path
challah-0.6.2 vendor/bundle/gems/yard-0.7.5/benchmarks/builtins_vs_eval.rb
challah-0.6.1 vendor/bundle/gems/yard-0.7.5/benchmarks/builtins_vs_eval.rb
challah-0.6.0 vendor/bundle/gems/yard-0.7.5/benchmarks/builtins_vs_eval.rb
challah-0.5.4 vendor/bundle/gems/yard-0.7.5/benchmarks/builtins_vs_eval.rb
challah-0.5.3 vendor/bundle/gems/yard-0.7.5/benchmarks/builtins_vs_eval.rb
challah-0.5.2 vendor/bundle/gems/yard-0.7.5/benchmarks/builtins_vs_eval.rb
challah-0.5.1 vendor/bundle/gems/yard-0.7.5/benchmarks/builtins_vs_eval.rb
challah-0.5.0 vendor/bundle/gems/yard-0.7.5/benchmarks/builtins_vs_eval.rb
challah-0.4.1 vendor/bundle/gems/yard-0.7.5/benchmarks/builtins_vs_eval.rb
challah-0.4.0 vendor/bundle/gems/yard-0.7.5/benchmarks/builtins_vs_eval.rb
challah-0.3.5 vendor/bundle/gems/yard-0.7.5/benchmarks/builtins_vs_eval.rb
challah-0.3.4 vendor/bundle/gems/yard-0.7.5/benchmarks/builtins_vs_eval.rb
challah-0.3.3 vendor/bundle/gems/yard-0.7.5/benchmarks/builtins_vs_eval.rb
challah-0.3.2 vendor/bundle/gems/yard-0.7.5/benchmarks/builtins_vs_eval.rb
challah-0.3.1 vendor/bundle/gems/yard-0.7.5/benchmarks/builtins_vs_eval.rb
challah-0.3.0 vendor/bundle/gems/yard-0.7.5/benchmarks/builtins_vs_eval.rb
challah-0.2.1 vendor/bundle/gems/yard-0.7.5/benchmarks/builtins_vs_eval.rb
challah-0.2.0 vendor/bundle/gems/yard-0.7.5/benchmarks/builtins_vs_eval.rb
yard-0.7.5 benchmarks/builtins_vs_eval.rb
nutshell-crm-0.0.6.alpha vendor/bundle/gems/yard-0.7.4/benchmarks/builtins_vs_eval.rb