138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
|
# File 'lib/tasks/xml_optimization_benchmark.rb', line 138
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
|