diff --git a/async-redis.gemspec b/async-redis.gemspec index 64182f8..c3b7446 100644 --- a/async-redis.gemspec +++ b/async-redis.gemspec @@ -28,4 +28,9 @@ Gem::Specification.new do |spec| spec.add_development_dependency "bundler" spec.add_development_dependency "rspec", "~> 3.6" spec.add_development_dependency "rake" + + # Dependencies with C extensions + if defined?(RUBY_ENGINE) && RUBY_ENGINE == "ruby" + spec.add_development_dependency "hiredis" + end end diff --git a/spec/async/redis/performance_spec.rb b/spec/async/redis/performance_spec.rb index c462137..90d40d2 100644 --- a/spec/async/redis/performance_spec.rb +++ b/spec/async/redis/performance_spec.rb @@ -31,6 +31,7 @@ let(:endpoint) {Async::Redis.local_endpoint} let(:async_client) {Async::Redis::Client.new(endpoint)} let(:redis_client) {Redis.new} + let(:redis_client_hiredis) {Redis.new(driver: :hiredis)} it "should be fast to set keys" do Benchmark.ips do |benchmark| @@ -65,6 +66,20 @@ expect(redis_client.get(key)).to be == value end end + + # Hiredis is C and not supported in JRuby and TruffleRuby. + if defined?(RUBY_ENGINE) && RUBY_ENGINE == "ruby" + benchmark.report("redis-rb (hiredis)") do |times| + key = keys.sample + value = times.to_s + + i = 0; while i < times; i += 1 + redis_client_hiredis.set(key, value) + expect(redis_client_hiredis.get(key)).to be == value + end + end + end + benchmark.compare! end