Skip to content

Instantly share code, notes, and snippets.

@mmmries
Last active August 10, 2017 20:35
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mmmries/9e606fb3dc3a2a1b6945b72cbb8e91a2 to your computer and use it in GitHub Desktop.
Save mmmries/9e606fb3dc3a2a1b6945b72cbb8e91a2 to your computer and use it in GitHub Desktop.
protobuf benchmarking

Protobuf Benchmarking

A really basic protobuf benchmark comparing the protobuf encoding/decoding performance. For details please see the benchmark.rb file in this gist and check the gpb benchmark files.

Latest Results

  • protobuf-3.6.12
  • gpb-3.26.6
runtime library encodes/sec decodes/sec
mri 2.4.0 protobuf 7,422 6,495
jruby-9.1.7.0 protobuf 10,384 8,325
beam-19.2 gpb 100,640 52,560
require "bundler/setup"
require "atlas"
require "benchmark/ips"
require "base64"
Atlas.initialize!
base64_proto_bytes = "Cp4DCihBQ1QtODA5MDMyY2ItYmEyMC00YjViLTRhZGMtMTRhNmVjYTI3NmM2EgZwYXlwYWwaKFVTUi1hZmMxMTJlMC1jNzFiLTQ4YjgtYzE4Mi0xMTVhYzk5ZTY5ODIiKE1CUi01ZGFkNDc0ZC0wOGViLTBiMWYtY2FlOS01ODI1MDk0Y2Y2ZjkqKElOUy02MmI1ZmUzZi03NmNjLWRkYzAtYzNiOS0wMDczMDExNjM1MjIyKEFHRy1iOTA5MDQzZi0wYTEzLTBjY2MtMTQ0OS03M2Q1YmI1NWNjN2Y6CnBheXBhbC5jb21AAVGPwvUoXG9IQFmPwvUoXG9IQMABAeEBj8L1KFxvSEDpAY/C9Shcb0hAogIKcGF5cGFsLmNvbcACAeACAegCAaADAcADAMgDANADANgDAOADAegDAPAD3JjXvwX4A6m7wb8FgATcmNe/BZAEBJgEAKAEALAEAZgFAKgFA7AGALoGKENMVC01ODU4ZWZkMS0yZDJlLTZhNWQtZjJiNS1jN2RhZDQyZWYxODTABgD4BgCABwPIDMgB"
proto_bytes = Base64.decode64(base64_proto_bytes)
accounts = ::Atlas::Abacus::Accounts.decode(proto_bytes)
Benchmark.ips do |x|
x.time = 30
x.warmup = 30
x.report("encode") { accounts.encode }
x.report("decode") { ::Atlas::Abacus::Accounts.decode(proto_bytes) }
end
# frozen_string_literal: true
source "https://rubygems.org"
gem "atlas", :source => "https://gems.internal.mx/"
gem "benchmark-ips"
GEM
remote: https://rubygems.org/
remote: https://gems.internal.mx/
specs:
activesupport (5.0.1)
concurrent-ruby (~> 1.0, >= 1.0.2)
i18n (~> 0.7)
minitest (~> 5.1)
tzinfo (~> 1.1)
atlas (4.16.4)
activesupport (>= 4.0)
ffi-rzmq (>= 2.0)
guid (>= 0.1.1)
protobuf (>= 3.0)
benchmark-ips (2.7.2)
concurrent-ruby (1.0.5)
concurrent-ruby (1.0.5-java)
ffi (1.9.17)
ffi (1.9.17-java)
ffi-rzmq (2.0.4)
ffi-rzmq-core (>= 1.0.1)
ffi-rzmq-core (1.0.5)
ffi
guid (0.1.1)
i18n (0.8.1)
middleware (0.1.0)
minitest (5.10.1)
protobuf (3.6.12)
activesupport (>= 3.2)
middleware
thor
thread_safe
thor (0.19.4)
thread_safe (0.3.6)
thread_safe (0.3.6-java)
tzinfo (1.2.2)
thread_safe (~> 0.1)
PLATFORMS
java
ruby
DEPENDENCIES
atlas!
benchmark-ips
BUNDLED WITH
1.14.3

2017-03-02

mri 2.4.0

  • atlas 4.16.4
  • protobuf 3.6.12
Warming up --------------------------------------
              encode   671.000  i/100ms
              decode   619.000  i/100ms
Calculating -------------------------------------
              encode      7.422k (± 5.2%) i/s -    222.101k in  30.014339s
              decode      6.495k (± 5.2%) i/s -    194.366k in  30.011716s

jRuby-9.1.7.0

  • atlas 4.16.4
  • protobuf 3.6.12
Warming up --------------------------------------
              encode     1.010k i/100ms
              decode   808.000  i/100ms
Calculating -------------------------------------
              encode     10.384k (± 3.2%) i/s -    312.090k in  30.085150s
              decode      8.325k (± 4.8%) i/s -    249.672k in  30.066696s

beam 19.2

  • gpb 3.26.6
Name                               ips        average  deviation         median
encode from partial data      641.98 K        1.56 μs  ±2484.88%        1.00 μs
encode                        102.76 K        9.73 μs   ±168.33%        8.00 μs
decode                         52.29 K       19.12 μs    ±62.95%       17.00 μs
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment