Sha256: 431fbeaaee907cebde30bc2a514505a54935b7914f669b2469f2d45291a5bc39
Contents?: true
Size: 883 Bytes
Versions: 1
Compression:
Stored size: 883 Bytes
Contents
Bundler.require(:benchmarks) class PlainRubyTest attr_reader :foo, :bar def initialize(foo: "FOO", bar: "BAR") @foo = foo @bar = bar end end require "dry-initializer" class DryTest extend Dry::Initializer option :foo, default: proc { "FOO" } option :bar, default: proc { "BAR" } end require "kwattr" class KwattrTest kwattr foo: "FOO", bar: "BAR" end require "active_attr" class ActiveAttrTest include ActiveAttr::AttributeDefaults attribute :foo, default: "FOO" attribute :bar, default: "BAR" end puts "Benchmark for instantiation with default values" Benchmark.ips do |x| x.config time: 15, warmup: 10 x.report("plain Ruby") do PlainRubyTest.new end x.report("dry-initializer") do DryTest.new end x.report("kwattr") do KwattrTest.new end x.report("active_attr") do ActiveAttrTest.new end x.compare! end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
dry-initializer-0.0.1 | benchmarks/with_defaults.rb |