Sha256: 116a63ec1efe182603b1004429cb934098e2a80c80548c28287dd2aff9f10d65
Contents?: true
Size: 1.13 KB
Versions: 2
Compression:
Stored size: 1.13 KB
Contents
#!/usr/bin/env ruby # frozen_string_literal: true require "bundler/setup" require "paquito" require "active_support" require "benchmark/ips" CODEC = Paquito::CodecFactory.build ORIGINAL = Paquito::SingleBytePrefixVersion.new( 0, 0 => Paquito.chain( Paquito::CacheEntryCoder, CODEC, ), ) FLAT = Paquito::FlatCacheEntryCoder.new( Paquito::SingleBytePrefixVersionWithStringBypass.new( 0, 0 => CODEC, ) ) entries = { small_string: "Hello World!", bytes_1mb: Random.bytes(1_000_000), int_array: 1000.times.to_a, } entries.each do |name, object| entry = ActiveSupport::Cache::Entry.new(object, expires_at: 15.minutes.from_now.to_f) original_payload = ORIGINAL.dump(entry).freeze flat_payload = FLAT.dump(entry).freeze puts " === Read #{name} ===" Benchmark.ips do |x| x.report("original") { ORIGINAL.load(original_payload) } x.report("flat") { FLAT.load(flat_payload) } x.compare!(order: :baseline) end puts " === Write #{name} ===" Benchmark.ips do |x| x.report("original") { ORIGINAL.dump(entry) } x.report("flat") { FLAT.dump(entry) } x.compare!(order: :baseline) end puts end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
paquito-0.9.1 | benchmark/flat-entry-coder.rb |
paquito-0.9.0 | benchmark/flat-entry-coder.rb |