Skip to content

Instantly share code, notes, and snippets.

@havenwood
Created July 3, 2018 21:16
Show Gist options
  • Save havenwood/f04f99a3050d17ae0cd152f6c86fcf8a to your computer and use it in GitHub Desktop.
Save havenwood/f04f99a3050d17ae0cd152f6c86fcf8a to your computer and use it in GitHub Desktop.
Pure Ruby xxHash Benchmark
# frozen_string_literal: true
require 'benchmark/ips'
require 'ruby-xxhash'
Benchmark.ips do |x|
text = 'chunky bacon'
seed = 12345
x.report('xxHash32') { XXhash.xxh32 text, seed }
x.report('xxHash64') { XXhash.xxh32 text, seed }
end
~ ruby -v
jruby 9.2.0.0 (2.5.0) 2018-05-24 81156a8 Java HotSpot(TM) 64-Bit Server VM 10.0.1+10 on 10.0.1+10 +jit [darwin-x86_64]
~ ruby -Xcompile.invokedynamic digest-xxhash-bench.rb
Warming up --------------------------------------
xxHash32 18.250k i/100ms
xxHash64 51.709k i/100ms
Calculating -------------------------------------
xxHash32 706.755k (± 5.6%) i/s - 3.522M in 5.000595s
xxHash64 717.427k (± 3.0%) i/s - 3.620M in 5.050095s
~ ruby -v
jruby 9.2.0.0 (2.5.0) 2018-05-24 81156a8 GraalVM 1.0.0-rc1 25.71-b01-internal-jvmci-0.42 on 1.8.0_161-b12 +jit [darwin-x86_64]
~ ruby -Xcompile.invokedynamic -Xfixnum.cache=false digest-xxhash-bench.rb
Warming up --------------------------------------
xxHash32 10.986k i/100ms
xxHash64 55.246k i/100ms
Calculating -------------------------------------
xxHash32 950.237k (± 9.8%) i/s - 4.702M in 5.002677s
xxHash64 947.486k (± 5.9%) i/s - 4.751M in 5.038389s
~ ruby -v
rubinius 3.104 (2.3.1 eced203d 2018-05-15 4.0.1) [x86_64-darwin17.5.0]
~ ruby digest-xxhash-bench.rb
Warming up --------------------------------------
xxHash32 3.842k i/100ms
xxHash64 4.019k i/100ms
Calculating -------------------------------------
xxHash32 45.204k (± 8.1%) i/s - 226.678k
xxHash64 45.229k (± 7.5%) i/s - 225.064k
~ ruby -v
ruby 2.5.1p57 (2018-03-29 revision 63029) [x86_64-darwin17]
~ ruby digest-xxhash-bench.rb
Warming up --------------------------------------
xxHash32 14.993k i/100ms
xxHash64 15.018k i/100ms
Calculating -------------------------------------
xxHash32 164.490k (± 2.3%) i/s - 824.615k in 5.015916s
xxHash64 164.180k (± 2.8%) i/s - 825.990k in 5.035278sx
~ ruby -v
truffleruby 1.0.0-rc3, like ruby 2.4.4, GraalVM CE Native [x86_64-darwin]
~ ruby digest-xxhash-bench.rb
Warming up --------------------------------------
xxHash32 86.879k i/100ms
xxHash64 86.938k i/100ms
Calculating -------------------------------------
xxHash32 1.187M (±20.3%) i/s - 5.647M in 5.077543s
xxHash64 1.175M (±15.7%) i/s - 5.738M in 5.063060s
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment