mirror of
https://github.com/isar/libmdbx.git
synced 2025-01-06 19:14:14 +08:00
mdbx-test: use common keygen-seed for ttl
testcase.
Change-Id: I921fff0ee28df8a18b6a38801c275de3fa2563ab
This commit is contained in:
parent
bfa9fc25d6
commit
3fc610f860
15
test/ttl.cc
15
test/ttl.cc
@ -16,18 +16,18 @@
|
|||||||
#include <cmath>
|
#include <cmath>
|
||||||
#include <queue>
|
#include <queue>
|
||||||
|
|
||||||
|
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) {
|
static unsigned edge2count(uint64_t edge, unsigned count_max) {
|
||||||
const double rnd = u64_to_double1(prng64_map1_white(edge));
|
const double rnd = u64_to_double1(prng64_map1_white(edge));
|
||||||
const unsigned count = std::lrint(std::pow(count_max, rnd));
|
const unsigned count = std::lrint(std::pow(count_max, rnd));
|
||||||
return count;
|
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() {
|
bool testcase_ttl::run() {
|
||||||
db_open();
|
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_read` value %u for window_max", window_max);
|
||||||
log_info("ttl: using `batch_write` value %u for count_max", count_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 */);
|
keyvalue_maker.setup(config.params, config.actor_id, 0 /* thread_number */);
|
||||||
key = keygen::alloc(config.params.keylen_max);
|
key = keygen::alloc(config.params.keylen_max);
|
||||||
data = keygen::alloc(config.params.datalen_max);
|
data = keygen::alloc(config.params.datalen_max);
|
||||||
@ -75,7 +76,7 @@ bool testcase_ttl::run() {
|
|||||||
while (should_continue()) {
|
while (should_continue()) {
|
||||||
if (!txn_guard)
|
if (!txn_guard)
|
||||||
txn_begin(false);
|
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);
|
const unsigned window = edge2window(salt, window_max);
|
||||||
log_trace("ttl: window %u at %" PRIu64, window, salt);
|
log_trace("ttl: window %u at %" PRIu64, window, salt);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user