Sha256: 475a4e59e37d141e19343423655b3ce7237b708c8d9152e04afb3524dc996484

Contents?: true

Size: 667 Bytes

Versions: 37

Compression:

Stored size: 667 Bytes

Contents

#!/usr/bin/env ruby
#
# Measures the encoded size of messages of increasing size.

$LOAD_PATH.unshift(File.expand_path("../lib", File.dirname(__FILE__)))

require 'benchmark'
require 'avro_turf'

sizes = [1, 10, 100, 1_000, 10_000]
avro = AvroTurf.new(schemas_path: File.dirname(__FILE__))

sizes.each do |size|
  data = {
    "name" => "John" * size,
    "address" => {
      "street" => "1st st." * size,
      "city" => "Citytown" * size
    }
  }

  result = avro.encode(data, schema_name: "person")
  encoded_size = result.bytesize
  encode_factor = result.bytesize / size.to_f
  puts "size #{size}: #{encoded_size} bytes (encoding factor #{encode_factor})"
end

Version data entries

37 entries across 37 versions & 2 rubygems

Version Path
avro_turf-1.17.0 perf/encoding_size.rb
avro_turf-1.16.0 perf/encoding_size.rb
avro_turf-1.15.0 perf/encoding_size.rb
avro_turf-1.14.0 perf/encoding_size.rb
avro_turf-1.13.0 perf/encoding_size.rb
avro_turf-1.12.0 perf/encoding_size.rb
avro_turf-1.11.0 perf/encoding_size.rb
avro_turf-1.10.0 perf/encoding_size.rb
avro_turf-1.9.0 perf/encoding_size.rb
avro_turf-1.8.0 perf/encoding_size.rb
avro_turf-1.7.0 perf/encoding_size.rb
avro_turf-1.6.0 perf/encoding_size.rb
avro_turf-1.5.0 perf/encoding_size.rb
avro_turf-1.4.1 perf/encoding_size.rb
avro_turf-1.4.0 perf/encoding_size.rb
avro_turf-1.3.1 perf/encoding_size.rb
avro_turf-1.3.0 perf/encoding_size.rb
avro_turf-1.2.0 perf/encoding_size.rb
avro_turf-1.1.0 perf/encoding_size.rb
avro_turf-1.0.0 perf/encoding_size.rb