File tree 2 files changed +28
-0
lines changed
2 files changed +28
-0
lines changed Original file line number Diff line number Diff line change 3
3
source 'https://rubygems.org'
4
4
gemspec name : 'redis-cluster-client'
5
5
6
+ gem 'async-redis' , platform : :mri
6
7
gem 'benchmark-ips'
7
8
gem 'hiredis-client' , '~> 0.6'
8
9
gem 'memory_profiler'
Original file line number Diff line number Diff line change 1
1
# frozen_string_literal: true
2
2
3
+ require 'async/redis/cluster_client'
3
4
require 'benchmark/ips'
4
5
require 'redis_cluster_client'
5
6
require 'testing_constants'
@@ -20,6 +21,7 @@ def run
20
21
envoy : envoy ,
21
22
cproxy : cluster_proxy
22
23
)
24
+ async_bench ( make_async_client )
23
25
end
24
26
25
27
def make_client
@@ -44,6 +46,11 @@ def make_client_for_cluster_proxy
44
46
) . new_client
45
47
end
46
48
49
+ def make_async_client
50
+ endpoints = TEST_NODE_URIS . map { |e | ::Async ::Redis ::Endpoint . parse ( e ) }
51
+ ::Async ::Redis ::ClusterClient . new ( endpoints )
52
+ end
53
+
47
54
def print_letter ( title )
48
55
print "################################################################################\n "
49
56
print "# #{ title } \n "
@@ -75,6 +82,26 @@ def bench(**kwargs)
75
82
x . compare!
76
83
end
77
84
end
85
+
86
+ def async_bench ( cluster )
87
+ Benchmark . ips do |x |
88
+ x . time = 5
89
+ x . warmup = 1
90
+
91
+ x . report ( 'single: async' ) do
92
+ Async do
93
+ ATTEMPTS . times do |i |
94
+ key = "key#{ i } "
95
+ slot = cluster . slot_for ( key )
96
+ client = cluster . client_for ( slot )
97
+ client . get ( key )
98
+ end
99
+ end
100
+ end
101
+
102
+ x . compare!
103
+ end
104
+ end
78
105
end
79
106
80
107
IpsSingle . run
You can’t perform that action at this time.
0 commit comments