Sha256: a847123556de459a1a850a6070a36f9868f5b22be9bafc55ad43d76f3a85150c

Contents?: true

Size: 644 Bytes

Versions: 1

Compression:

Stored size: 644 Bytes

Contents

Bundler.require(:benchmarks)

require "dry-initializer"

class ParamDefaults
  extend Dry::Initializer

  param :foo, default: proc { "FOO" }
  param :bar, default: proc { "BAR" }
  param :baz, default: proc { "BAZ" }
end

class OptionDefaults
  extend Dry::Initializer

  option :foo, default: proc { "FOO" }
  option :bar, default: proc { "BAR" }
  option :baz, default: proc { "BAZ" }
end

puts "Benchmark for param's vs. option's defaults"

Benchmark.ips do |x|
  x.config time: 15, warmup: 10

  x.report("param's defaults") do
    ParamDefaults.new
  end

  x.report("option's defaults") do
    OptionDefaults.new
  end

  x.compare!
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
dry-initializer-0.0.1 benchmarks/params_vs_options.rb