From 3fc610f8602fefbe6b84c0d84b197c426994219d Mon Sep 17 00:00:00 2001 From: Leonid Yuriev Date: Sat, 22 Jun 2019 12:42:19 +0300 Subject: [PATCH] mdbx-test: use common keygen-seed for `ttl` testcase. Change-Id: I921fff0ee28df8a18b6a38801c275de3fa2563ab --- test/ttl.cc | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/test/ttl.cc b/test/ttl.cc index 14a6b128..a625a8e7 100644 --- a/test/ttl.cc +++ b/test/ttl.cc @@ -16,18 +16,18 @@ #include #include +static unsigned edge2window(uint64_t edge, unsigned window_max) { + const double rnd = u64_to_double1(bleach64(edge)); + const unsigned window = window_max - std::lrint(std::pow(window_max, rnd)); + return window - (window > 0); +} + static unsigned edge2count(uint64_t edge, unsigned count_max) { const double rnd = u64_to_double1(prng64_map1_white(edge)); const unsigned count = std::lrint(std::pow(count_max, rnd)); return count; } -static unsigned edge2window(uint64_t edge, unsigned window_max) { - const double rnd = u64_to_double1(prng64_map2_white(edge)); - const unsigned window = window_max - std::lrint(std::pow(window_max, rnd)); - return window - (window > 0); -} - bool testcase_ttl::run() { db_open(); @@ -63,6 +63,7 @@ bool testcase_ttl::run() { log_info("ttl: using `batch_read` value %u for window_max", window_max); log_info("ttl: using `batch_write` value %u for count_max", count_max); + uint64_t seed = prng64_map2_white(config.params.keygen.seed) + config.actor_id; keyvalue_maker.setup(config.params, config.actor_id, 0 /* thread_number */); key = keygen::alloc(config.params.keylen_max); data = keygen::alloc(config.params.datalen_max); @@ -75,7 +76,7 @@ bool testcase_ttl::run() { while (should_continue()) { if (!txn_guard) txn_begin(false); - const uint64_t salt = mdbx_txn_id(txn_guard.get()); + const uint64_t salt = prng64_white(seed)/* mdbx_txn_id(txn_guard.get()) */; const unsigned window = edge2window(salt, window_max); log_trace("ttl: window %u at %" PRIu64, window, salt);