Sha256: 39c2b71e089af4ca068c7f154c0a19ce20423d80f6b40ab31ba1c0de13e299ef
Contents?: true
Size: 1.52 KB
Versions: 1
Compression:
Stored size: 1.52 KB
Contents
Bundler.require(:benchmarks) require 'dry-initializer' class WithoutDefaults extend Dry::Initializer param :foo param :bar param :baz end class WithOneDefault extend Dry::Initializer param :foo param :bar param :baz, default: proc { 'BAZ' } end class WithTwoDefaults extend Dry::Initializer param :foo param :bar, default: proc { 'BAR' } param :baz, default: proc { 'BAZ' } end class WithThreeDefaults extend Dry::Initializer param :foo, default: proc { 'FOO' } param :bar, default: proc { 'BAR' } param :baz, default: proc { 'BAZ' } end puts 'Benchmark for various options' Benchmark.ips do |x| x.config time: 15, warmup: 10 x.report('without defaults') do WithoutDefaults.new 'FOO', 'BAR', 'BAZ' end x.report('with 0 of 1 default used') do WithOneDefault.new 'FOO', 'BAR', 'BAZ' end x.report('with 1 of 1 default used') do WithOneDefault.new 'FOO', 'BAR' end x.report('with 0 of 2 defaults used') do WithTwoDefaults.new 'FOO', 'BAR', 'BAZ' end x.report('with 1 of 2 defaults used') do WithTwoDefaults.new 'FOO', 'BAR' end x.report('with 2 of 2 defaults used') do WithTwoDefaults.new 'FOO' end x.report('with 0 of 3 defaults used') do WithThreeDefaults.new 'FOO', 'BAR', 'BAZ' end x.report('with 1 of 3 defaults used') do WithThreeDefaults.new 'FOO', 'BAR' end x.report('with 2 of 3 defaults used') do WithThreeDefaults.new 'FOO' end x.report('with 3 of 3 defaults used') do WithThreeDefaults.new end x.compare! end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
dry-initializer-3.0.3 | benchmarks/compare_several_defaults.rb |