Skip to content

Commit 361d752

Browse files
authored
test: keep pipelining size in moderation for benchmarks (#176)
1 parent efd037d commit 361d752

File tree

2 files changed

+17
-10
lines changed

2 files changed

+17
-10
lines changed

test/benchmark_mixin.rb

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
module BenchmarkMixin
44
MIN_THRESHOLD = 0.95
5+
MAX_PIPELINE_SIZE = 30
56

67
def setup
78
@client = new_test_client
@@ -41,29 +42,35 @@ def bench_get
4142

4243
def bench_pipeline_echo
4344
assert_performance_linear(MIN_THRESHOLD) do |n|
44-
@client.pipelined do |pi|
45-
n.times do
46-
pi.call('ECHO', 'Hello world')
45+
(1..n).each_slice(MAX_PIPELINE_SIZE) do |list|
46+
@client.pipelined do |pi|
47+
list.each do
48+
pi.call('ECHO', 'Hello world')
49+
end
4750
end
4851
end
4952
end
5053
end
5154

5255
def bench_pipeline_set
5356
assert_performance_linear(MIN_THRESHOLD) do |n|
54-
@client.pipelined do |pi|
55-
n.times do |i|
56-
pi.call('SET', "key#{i}", i)
57+
(1..n).each_slice(MAX_PIPELINE_SIZE) do |list|
58+
@client.pipelined do |pi|
59+
list.each do |i|
60+
pi.call('SET', "key#{i}", i)
61+
end
5762
end
5863
end
5964
end
6065
end
6166

6267
def bench_pipeline_get
6368
assert_performance_linear(MIN_THRESHOLD) do |n|
64-
@client.pipelined do |pi|
65-
n.times do |i|
66-
pi.call('GET', "key#{i}")
69+
(1..n).each_slice(MAX_PIPELINE_SIZE) do |list|
70+
@client.pipelined do |pi|
71+
list.each do |i|
72+
pi.call('GET', "key#{i}")
73+
end
6774
end
6875
end
6976
end

test/prof_mem.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ module ProfMem
99

1010
ATTEMPT_COUNT = 1000
1111
MAX_PIPELINE_SIZE = 30
12-
SLICED_NUMBERS = Array.new(ATTEMPT_COUNT) { |i| i }.each_slice(MAX_PIPELINE_SIZE).freeze
12+
SLICED_NUMBERS = (1..ATTEMPT_COUNT).each_slice(MAX_PIPELINE_SIZE).freeze
1313
CLI_TYPES = %w[primary_only scale_read_random scale_read_latency pooled].freeze
1414
MODES = {
1515
single: lambda do |client_builder_method|

0 commit comments

Comments
 (0)