Sha256: 72df4fb1f5fd2970cc484d841af5bd86120f1aabddf6bc718000b872c1b132f9
Contents?: true
Size: 1.34 KB
Versions: 1
Compression:
Stored size: 1.34 KB
Contents
Bundler.require(:benchmarks) require 'dry-initializer' class DryTest extend Dry::Initializer[undefined: false] param :foo param :bar end class DryTestUndefined extend Dry::Initializer param :foo param :bar end class PlainRubyTest attr_reader :foo, :bar def initialize(foo, bar) @foo = foo @bar = bar end end StructTest = Struct.new(:foo, :bar) require 'concord' class ConcordTest include Concord.new(:foo, :bar) end require 'values' ValueTest = Value.new(:foo, :bar) require 'value_struct' ValueStructTest = ValueStruct.new(:foo, :bar) require 'attr_extras' class AttrExtrasText attr_initialize :foo, :bar attr_reader :foo, :bar end puts 'Benchmark for instantiation with plain params' Benchmark.ips do |x| x.config time: 15, warmup: 10 x.report('plain Ruby') do PlainRubyTest.new 'FOO', 'BAR' end x.report('Core Struct') do StructTest.new 'FOO', 'BAR' end x.report('values') do ValueTest.new 'FOO', 'BAR' end x.report('value_struct') do ValueStructTest.new 'FOO', 'BAR' end x.report('dry-initializer') do DryTest.new 'FOO', 'BAR' end x.report('dry-initializer (with UNDEFINED)') do DryTestUndefined.new 'FOO', 'BAR' end x.report('concord') do ConcordTest.new 'FOO', 'BAR' end x.report('attr_extras') do AttrExtrasText.new 'FOO', 'BAR' end x.compare! end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
dry-initializer-3.0.3 | benchmarks/plain_params.rb |