summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSalvatore Sanfilippo <antirez@gmail.com>2020-05-19 16:16:38 +0200
committerGitHub <noreply@github.com>2020-05-19 16:16:38 +0200
commitd949e8fe1882d280c3678403c16e778ef2d5f0f0 (patch)
treea58fa9f6e930241f8d05aa59ffdff15dc7c7f56e
parenta9200ed0b35ec9ae70ba85006c66050f36870429 (diff)
parentabff264000a9926bb7b96172fd49dae3b804c4e0 (diff)
downloadredis-d949e8fe1882d280c3678403c16e778ef2d5f0f0.tar.gz
Merge pull request #7196 from ShooterIT/benchmark
Redis Benchmark: make test data better
-rw-r--r--src/redis-benchmark.c13
1 files changed, 12 insertions, 1 deletions
diff --git a/src/redis-benchmark.c b/src/redis-benchmark.c
index 46c1853f7..38d4ca51b 100644
--- a/src/redis-benchmark.c
+++ b/src/redis-benchmark.c
@@ -1278,6 +1278,17 @@ static void updateClusterSlotsConfiguration() {
pthread_mutex_unlock(&config.is_updating_slots_mutex);
}
+/* Generate random data for redis benchmark. See #7196. */
+static void genBenchmarkRandomData(char *data, int count) {
+ static uint32_t state = 1234;
+ int i = 0;
+
+ while (count--) {
+ state = (state*1103515245+12345);
+ data[i++] = '0'+((state>>16)&63);
+ }
+}
+
/* Returns number of consumed options. */
int parseOptions(int argc, const char **argv) {
int i;
@@ -1632,7 +1643,7 @@ int main(int argc, const char **argv) {
/* Run default benchmark suite. */
data = zmalloc(config.datasize+1);
do {
- memset(data,'x',config.datasize);
+ genBenchmarkRandomData(data, config.datasize);
data[config.datasize] = '\0';
if (test_is_selected("ping_inline") || test_is_selected("ping"))