Sha256: b1db60493ccdc594a42cd3a6b0fdce71530d13bf6c597f7292bb20e763c10315
Contents?: true
Size: 1.32 KB
Versions: 2
Compression:
Stored size: 1.32 KB
Contents
# frozen_string_literal: true require_relative "benchmarking_support" require_relative "app" require_relative "setup" class AuthorFastSerializer < Panko::Serializer attributes :id, :name end class PostFastSerializer < Panko::Serializer attributes :id, :body, :title, :author_id end class PostWithHasOneFastSerializer < Panko::Serializer attributes :id, :body, :title, :author_id has_one :author, serializer: AuthorFastSerializer end class AuthorWithHasManyFastSerializer < Panko::Serializer attributes :id, :name has_many :posts, serializer: PostFastSerializer end def benchmark(prefix, serializer, options = {}) data = Benchmark.data posts = data[:all] posts_50 = data[:small] merged_options = options.merge(each_serializer: serializer) Benchmark.run("Panko_ActiveRecord_#{prefix}_Posts_#{posts.count}") do Panko::ArraySerializer.new(posts, merged_options).to_a end data = Benchmark.data posts = data[:all] posts_50 = data[:small] Benchmark.run("Panko_ActiveRecord_#{prefix}_Posts_50") do Panko::ArraySerializer.new(posts_50, merged_options).to_a end end benchmark "Simple", PostFastSerializer benchmark "HasOne", PostWithHasOneFastSerializer benchmark "Except", PostWithHasOneFastSerializer, except: [:title] benchmark "Only", PostWithHasOneFastSerializer, only: [:id, :body, :author_id, :author]
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
panko_serializer-0.8.2 | benchmarks/bm_panko_object.rb |
panko_serializer-0.8.1 | benchmarks/bm_panko_object.rb |