Sha256: 84c612919ba238f4ef5a5aa44147db70c28b81b349d6f8e364756fd79afaffdf

Contents?: true

Size: 594 Bytes

Versions: 2

Compression:

Stored size: 594 Bytes

Contents

# frozen_string_literal: true

require_relative "benchmarking_support"
require_relative "app"
require_relative "setup"

require "memory_profiler"

class PostFastSerializer < Panko::Serializer
  attributes :id, :body, :title, :author_id
end

def count_allocs(&block)
  memory_report = MemoryProfiler.report(&block)
  puts memory_report.pretty_print
end

posts = Post.all.to_a
merged_options = {}.merge(each_serializer: PostFastSerializer)
posts_array_serializer = Panko::ArraySerializer.new([], merged_options)

# prints out 18402
count_allocs { posts_array_serializer.serialize_to_json posts }

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
panko_serializer-0.8.2 benchmarks/allocs.rb
panko_serializer-0.8.1 benchmarks/allocs.rb