Sha256: f2d3cf9797b1b4aef07a1fd8df1ffa72916599da67c51e820df0ab508b38bb42

Contents?: true

Size: 807 Bytes

Versions: 23

Compression:

Stored size: 807 Bytes

Contents

Bundler.require(:benchmarks)

class PlainRubyTest
  attr_reader :foo, :bar

  def initialize(foo:, bar:)
    @foo = foo
    @bar = bar
  end
end

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

  option :foo
  option :bar
end

require "anima"
class AnimaTest
  include Anima.new(:foo, :bar)
end

require "kwattr"
class KwattrTest
  kwattr :foo, :bar
end

puts "Benchmark for instantiation without options"

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

  x.report("plain Ruby") do
    PlainRubyTest.new foo: "FOO", bar: "BAR"
  end

  x.report("dry-initializer") do
    DryTest.new foo: "FOO", bar: "BAR"
  end

  x.report("anima") do
    AnimaTest.new foo: "FOO", bar: "BAR"
  end

  x.report("kwattr") do
    KwattrTest.new foo: "FOO", bar: "BAR"
  end

  x.compare!
end

Version data entries

23 entries across 23 versions & 1 rubygems

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