Sha256: 311a9de46537f25a1b3b734148e4085235105f8e0f6311303d46242e9c9ed7ec
Contents?: true
Size: 1.29 KB
Versions: 22
Compression:
Stored size: 1.29 KB
Contents
# frozen_string_literal: true require_relative "./benchmarking_support" require "active_support" require "panko_serializer" def generate_attributes(count) (1..count).map { |i| "attr_#{i}".to_sym } end class LeafASerializer < Panko::Serializer attributes *generate_attributes(5) end class LeafBSerializer < Panko::Serializer attributes *generate_attributes(6) end class ChildrenSerializer < Panko::Serializer attributes *generate_attributes(28) has_one :leaf_a, serializer: LeafASerializer has_one :leaf_b, serializer: LeafBSerializer def attr_1 end def attr_2 end def attr_3 end def attr_4 end def attr_5 end end class ParentSerializer < Panko::Serializer attributes *generate_attributes(46) has_many :children, serializer: ChildrenSerializer def attr_1 end def attr_2 end def attr_3 end def attr_4 end end attrs = generate_attributes(21) attrs << :children filters = { instance: attrs, children: generate_attributes(11) } Benchmark.run("NoFilters") do Panko::SerializationDescriptor.build(ParentSerializer) end Benchmark.run("Attribute") do Panko::SerializationDescriptor.build(ParentSerializer, only: [:children]) end Benchmark.run("AssociationFilters") do Panko::SerializationDescriptor.build(ParentSerializer, only: filters) end
Version data entries
22 entries across 22 versions & 1 rubygems
Version | Path |
---|---|
panko_serializer-0.4.4 | benchmarks/bm_serialization_descriptor.rb |
panko_serializer-0.4.3 | benchmarks/bm_serialization_descriptor.rb |