Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
165 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
# frozen_string_literal: true | ||
|
||
require_relative "setup" | ||
|
||
ruby = RedisClient.new(host: "localhost", port: Servers::REDIS.real_port, driver: :ruby) | ||
hiredis = RedisClient.new(host: "localhost", port: Servers::REDIS.real_port, driver: :hiredis) | ||
|
||
ruby.call("SET", "key", "value") | ||
ruby.call("SET", "large", "value" * 10_000) | ||
ruby.call("LPUSH", "list", *5.times.to_a) | ||
ruby.call("LPUSH", "large-list", *1000.times.to_a) | ||
ruby.call("HMSET", "hash", *8.times.to_a) | ||
ruby.call("HMSET", "large-hash", *1000.times.to_a) | ||
|
||
benchmark("small string x 100") do |x| | ||
x.report("hiredis") { hiredis.pipelined { |p| 100.times { p.call("GET", "key") } } } | ||
x.report("ruby") { ruby.pipelined { |p| 100.times { p.call("GET", "key") } } } | ||
end | ||
|
||
benchmark("large string x 100") do |x| | ||
x.report("hiredis") { hiredis.pipelined { |p| 100.times { p.call("GET", "large") } } } | ||
x.report("ruby") { ruby.pipelined { |p| 100.times { p.call("GET", "large") } } } | ||
end | ||
|
||
benchmark("small list x 100") do |x| | ||
x.report("hiredis") { hiredis.pipelined { |p| 100.times { p.call("LRANGE", "list", 0, -1) } } } | ||
x.report("ruby") { ruby.pipelined { |p| 100.times { p.call("LRANGE", "list", 0, -1) } } } | ||
end | ||
|
||
benchmark("large list") do |x| | ||
x.report("hiredis") { hiredis.call("LRANGE", "large-list", 0, -1) } | ||
x.report("ruby") { ruby.call("LRANGE", "large-list", 0, -1) } | ||
end | ||
|
||
benchmark("small hash x 100") do |x| | ||
x.report("hiredis") { hiredis.pipelined { |p| 100.times { p.call("HGETALL", "hash") } } } | ||
x.report("ruby") { ruby.pipelined { |p| 100.times { p.call("HGETALL", "hash") } } } | ||
end | ||
|
||
benchmark("large hash") do |x| | ||
x.report("hiredis") { ruby.call("HGETALL", "large-hash") } | ||
x.report("ruby") { ruby.call("HGETALL", "large-hash") } | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
ruby: `ruby 3.3.0 (2023-12-25 revision 5124f9ac75) [arm64-darwin23]` | ||
|
||
redis-server: `Redis server v=7.0.12 sha=00000000:0 malloc=libc bits=64 build=a11d0151eabf466c` | ||
|
||
|
||
### small string x 100 | ||
|
||
``` | ||
ruby 3.3.0 (2023-12-25 revision 5124f9ac75) [arm64-darwin23] | ||
hiredis: 5402.4 i/s | ||
ruby: 2877.9 i/s - 1.88x slower | ||
``` | ||
|
||
### large string x 100 | ||
|
||
``` | ||
ruby 3.3.0 (2023-12-25 revision 5124f9ac75) [arm64-darwin23] | ||
hiredis: 297.2 i/s | ||
ruby: 291.2 i/s - same-ish: difference falls within error | ||
``` | ||
|
||
### small list x 100 | ||
|
||
``` | ||
ruby 3.3.0 (2023-12-25 revision 5124f9ac75) [arm64-darwin23] | ||
hiredis: 2632.0 i/s | ||
ruby: 1136.1 i/s - 2.32x slower | ||
``` | ||
|
||
### large list | ||
|
||
``` | ||
ruby 3.3.0 (2023-12-25 revision 5124f9ac75) [arm64-darwin23] | ||
hiredis: 6640.8 i/s | ||
ruby: 1293.1 i/s - 5.14x slower | ||
``` | ||
|
||
### small hash x 100 | ||
|
||
``` | ||
ruby 3.3.0 (2023-12-25 revision 5124f9ac75) [arm64-darwin23] | ||
hiredis: 3419.6 i/s | ||
ruby: 1129.0 i/s - 3.03x slower | ||
``` | ||
|
||
### large hash | ||
|
||
``` | ||
ruby 3.3.0 (2023-12-25 revision 5124f9ac75) [arm64-darwin23] | ||
hiredis: 1299.3 i/s | ||
ruby: 1275.3 i/s - same-ish: difference falls within error | ||
``` | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
ruby: `ruby 3.3.0 (2023-12-25 revision 5124f9ac75) [arm64-darwin23]` | ||
|
||
redis-server: `Redis server v=7.0.12 sha=00000000:0 malloc=libc bits=64 build=a11d0151eabf466c` | ||
|
||
|
||
### small string x 100 | ||
|
||
``` | ||
ruby 3.3.0 (2023-12-25 revision 5124f9ac75) +YJIT [arm64-darwin23] | ||
hiredis: 6745.7 i/s | ||
ruby: 5182.0 i/s - 1.30x slower | ||
``` | ||
|
||
### large string x 100 | ||
|
||
``` | ||
ruby 3.3.0 (2023-12-25 revision 5124f9ac75) +YJIT [arm64-darwin23] | ||
hiredis: 303.5 i/s | ||
ruby: 343.1 i/s - 1.13x faster | ||
``` | ||
|
||
### small list x 100 | ||
|
||
``` | ||
ruby 3.3.0 (2023-12-25 revision 5124f9ac75) +YJIT [arm64-darwin23] | ||
hiredis: 3683.6 i/s | ||
ruby: 1952.3 i/s - 1.89x slower | ||
``` | ||
|
||
### large list | ||
|
||
``` | ||
ruby 3.3.0 (2023-12-25 revision 5124f9ac75) +YJIT [arm64-darwin23] | ||
hiredis: 6540.2 i/s | ||
ruby: 2710.0 i/s - 2.41x slower | ||
``` | ||
|
||
### small hash x 100 | ||
|
||
``` | ||
ruby 3.3.0 (2023-12-25 revision 5124f9ac75) +YJIT [arm64-darwin23] | ||
hiredis: 4002.6 i/s | ||
ruby: 2317.0 i/s - 1.73x slower | ||
``` | ||
|
||
### large hash | ||
|
||
``` | ||
ruby 3.3.0 (2023-12-25 revision 5124f9ac75) +YJIT [arm64-darwin23] | ||
hiredis: 2467.1 i/s | ||
ruby: 2439.0 i/s - same-ish: difference falls within error | ||
``` | ||
|