Sha256: 448524ed9ecaa997c63f4650d09d9929c16f2b4b89bd63c138d11845157aa372

Contents?: true

Size: 944 Bytes

Versions: 22

Compression:

Stored size: 944 Bytes

Contents

Bundler.require(:benchmarks)

require "dry-initializer"
class NoOptsTest
  extend Dry::Initializer::Mixin

  param  :foo
  option :bar
end

class DefaultsTest
  extend Dry::Initializer::Mixin

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

class TypesTest
  extend Dry::Initializer::Mixin

  param  :foo, type: String
  option :bar, type: String
end

class DefaultsAndTypesTest
  extend Dry::Initializer::Mixin

  param  :foo, type: String, default: proc { "FOO" }
  option :bar, type: String, default: proc { "BAR" }
end

puts "Benchmark for various options"

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

  x.report("no opts") do
    NoOptsTest.new "foo", bar: "bar"
  end

  x.report("with defaults") do
    DefaultsTest.new
  end

  x.report("with types") do
    TypesTest.new "foo", bar: "bar"
  end

  x.report("with defaults and types") do
    DefaultsAndTypesTest.new
  end

  x.compare!
end

Version data entries

22 entries across 22 versions & 1 rubygems

Version Path
dry-initializer-0.11.0 benchmarks/options.rb
dry-initializer-0.10.2 benchmarks/options.rb
dry-initializer-0.10.1 benchmarks/options.rb
dry-initializer-0.10.0 benchmarks/options.rb
dry-initializer-0.9.3 benchmarks/options.rb
dry-initializer-0.9.2 benchmarks/options.rb
dry-initializer-0.9.1 benchmarks/options.rb
dry-initializer-0.9.0 benchmarks/options.rb
dry-initializer-0.8.1 benchmarks/options.rb
dry-initializer-0.8.0 benchmarks/options.rb
dry-initializer-0.7.0 benchmarks/options.rb
dry-initializer-0.6.0 benchmarks/options.rb
dry-initializer-0.5.0 benchmarks/options.rb
dry-initializer-0.4.0 benchmarks/options.rb
dry-initializer-0.3.3 benchmarks/options.rb
dry-initializer-0.3.2 benchmarks/options.rb
dry-initializer-0.3.1 benchmarks/options.rb
dry-initializer-0.3.0 benchmarks/options.rb
dry-initializer-0.2.1 benchmarks/options.rb
dry-initializer-0.2.0 benchmarks/options.rb