From 8ce15e56232b01aa5fd81e8bd24ddf8a35264582 Mon Sep 17 00:00:00 2001 From: Ran Shidlansik Date: Wed, 3 Sep 2025 13:00:31 +0300 Subject: [PATCH 1/2] valkey-benchmark - introduce test scenarios for ZCORE, ZRANGE and SISMEMBER This can help improve the used test scenarios in our performance benchmark Signed-off-by: Ran Shidlansik --- src/valkey-benchmark.c | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/src/valkey-benchmark.c b/src/valkey-benchmark.c index 284f33b3f8..f222be2517 100644 --- a/src/valkey-benchmark.c +++ b/src/valkey-benchmark.c @@ -2338,6 +2338,12 @@ int main(int argc, char **argv) { free(cmd); } + if (test_is_selected("sismember")) { + len = valkeyFormatCommand(&cmd, "SISMEMBER myset%s element:__rand_int__", tag); + benchmark("SISMEMBER", cmd, len); + free(cmd); + } + if (test_is_selected("zadd")) { char *score = "0"; if (config.replace_placeholders) score = "__rand_int__"; @@ -2352,6 +2358,19 @@ int main(int argc, char **argv) { free(cmd); } + if (test_is_selected("zscore")) { + len = valkeyFormatCommand(&cmd, "ZSCORE myzset%s element:__rand_1st__", tag); + benchmark("ZSCORE", cmd, len); + free(cmd); + } + + if (test_is_selected("zrange")) { + int score_min = (config.keyspacelen != 0) ? (random() % config.keyspacelen) : 0; + len = valkeyFormatCommand(&cmd, "ZRANGE myzset%s %d +inf BYSCORE LIMIT 0 1", tag, score_min); + benchmark("ZRANGE", cmd, len); + free(cmd); + } + if (test_is_selected("lrange") || test_is_selected("lrange_100") || test_is_selected("lrange_300") || test_is_selected("lrange_500") || test_is_selected("lrange_600")) { len = valkeyFormatCommand(&cmd, "LPUSH mylist%s %s", tag, data); From 1ebb4035391f1947e4915c82344cc9e2a069d2ef Mon Sep 17 00:00:00 2001 From: Ran Shidlansik Date: Wed, 3 Sep 2025 14:04:22 +0300 Subject: [PATCH 2/2] change tests order Signed-off-by: Ran Shidlansik --- src/valkey-benchmark.c | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/src/valkey-benchmark.c b/src/valkey-benchmark.c index f222be2517..a033fd0d47 100644 --- a/src/valkey-benchmark.c +++ b/src/valkey-benchmark.c @@ -2320,21 +2320,15 @@ int main(int argc, char **argv) { free(cmd); } - if (test_is_selected("sadd")) { - len = valkeyFormatCommand(&cmd, "SADD myset%s element:__rand_int__", tag); - benchmark("SADD", cmd, len); - free(cmd); - } - if (test_is_selected("hset")) { len = valkeyFormatCommand(&cmd, "HSET myhash%s element:__rand_int__ %s", tag, data); benchmark("HSET", cmd, len); free(cmd); } - if (test_is_selected("spop")) { - len = valkeyFormatCommand(&cmd, "SPOP myset%s", tag); - benchmark("SPOP", cmd, len); + if (test_is_selected("sadd")) { + len = valkeyFormatCommand(&cmd, "SADD myset%s element:__rand_int__", tag); + benchmark("SADD", cmd, len); free(cmd); } @@ -2344,6 +2338,12 @@ int main(int argc, char **argv) { free(cmd); } + if (test_is_selected("spop")) { + len = valkeyFormatCommand(&cmd, "SPOP myset%s", tag); + benchmark("SPOP", cmd, len); + free(cmd); + } + if (test_is_selected("zadd")) { char *score = "0"; if (config.replace_placeholders) score = "__rand_int__"; @@ -2352,12 +2352,6 @@ int main(int argc, char **argv) { free(cmd); } - if (test_is_selected("zpopmin")) { - len = valkeyFormatCommand(&cmd, "ZPOPMIN myzset%s", tag); - benchmark("ZPOPMIN", cmd, len); - free(cmd); - } - if (test_is_selected("zscore")) { len = valkeyFormatCommand(&cmd, "ZSCORE myzset%s element:__rand_1st__", tag); benchmark("ZSCORE", cmd, len); @@ -2371,6 +2365,12 @@ int main(int argc, char **argv) { free(cmd); } + if (test_is_selected("zpopmin")) { + len = valkeyFormatCommand(&cmd, "ZPOPMIN myzset%s", tag); + benchmark("ZPOPMIN", cmd, len); + free(cmd); + } + if (test_is_selected("lrange") || test_is_selected("lrange_100") || test_is_selected("lrange_300") || test_is_selected("lrange_500") || test_is_selected("lrange_600")) { len = valkeyFormatCommand(&cmd, "LPUSH mylist%s %s", tag, data);