Sha256: 9bd95fbe08cfb9f1f097ed5aad9f7112af38c131274696a2fa936249a88a9c17

Contents?: true

Size: 984 Bytes

Versions: 43

Compression:

Stored size: 984 Bytes

Contents

# frozen_string_literal: true
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.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

43 entries across 42 versions & 7 rubygems

Version Path
kinetic_sdk-5.0.25 gems/yard-0.9.25/benchmarks/builtins_vs_eval.rb
kinetic_sdk-5.0.24 gems/yard-0.9.25/benchmarks/builtins_vs_eval.rb
kinetic_sdk-5.0.23 gems/yard-0.9.25/benchmarks/builtins_vs_eval.rb
kinetic_sdk-5.0.22 gems/yard-0.9.25/benchmarks/builtins_vs_eval.rb
kinetic_sdk-5.0.21 gems/yard-0.9.25/benchmarks/builtins_vs_eval.rb
devcycle-ruby-server-sdk-2.0.0 vendor/bundle/ruby/3.0.0/gems/yard-0.9.28/benchmarks/builtins_vs_eval.rb
kinetic_sdk-5.0.20 gems/yard-0.9.25/benchmarks/builtins_vs_eval.rb
yard-0.9.28 benchmarks/builtins_vs_eval.rb
yard-0.9.27 benchmarks/builtins_vs_eval.rb
yard-0.9.26 benchmarks/builtins_vs_eval.rb
qiita_org-0.1.35 gems/ruby/2.7.0/gems/yard-0.9.25/benchmarks/builtins_vs_eval.rb
qiita_org-0.1.34 gems/ruby/2.7.0/gems/yard-0.9.25/benchmarks/builtins_vs_eval.rb
qiita_org-0.1.33 gems/ruby/2.7.0/gems/yard-0.9.25/benchmarks/builtins_vs_eval.rb
qiita_org-0.1.32 gems/ruby/2.7.0/gems/yard-0.9.25/benchmarks/builtins_vs_eval.rb
qiita_org-0.1.31 gems/ruby/2.7.0/gems/yard-0.9.25/benchmarks/builtins_vs_eval.rb
qiita_org-0.1.30 gems/ruby/2.7.0/gems/yard-0.9.25/benchmarks/builtins_vs_eval.rb
qiita_org-0.1.29 gems/ruby/2.7.0/gems/yard-0.9.25/benchmarks/builtins_vs_eval.rb
qiita_org-0.1.28 gems/ruby/2.7.0/gems/yard-0.9.25/benchmarks/builtins_vs_eval.rb
qiita_org-0.1.27 gems/ruby/2.7.0/gems/yard-0.9.25/benchmarks/builtins_vs_eval.rb
qiita_org-0.1.26 gems/ruby/2.7.0/gems/yard-0.9.25/benchmarks/builtins_vs_eval.rb