class CollectionHandlerBenchmark
def initialize(run_time: nil)
def initialize(run_time: nil) @run_time = run_time || 10 end
def run
def run puts "-" * 40 puts "CollectionHandler Memoization Benchmark" puts "-" * 40 bench_class = Class.new(Lutaml::Model::Serializable) do attribute :items, :string, collection: true attribute :single, :string attribute :custom_coll, :string, collection: SomeCollection end attr_defs = bench_class.attributes.values job = Benchmark::IPS::Job.new job.config(time: @run_time, warmup: 3) job.report("collection? (memoized)") do attr_defs.each(&:collection?) end job.report("singular? (memoized)") do attr_defs.each(&:singular?) end job.report("collection_class (memoized)") do attr_defs.each(&:collection_class) end job.run puts end