From 193a1ed2acb24b091746d1bf318862709c3698d4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=99=88=E4=BA=88=E6=9B=88?= <10222140454@stu.ecnu.edu.cn> Date: Tue, 29 Oct 2024 14:09:13 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E9=9A=8F=E6=9C=BA=E7=A7=8D?= =?UTF-8?q?=E5=AD=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- leveldb_base/test/ttl_test.cc | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/leveldb_base/test/ttl_test.cc b/leveldb_base/test/ttl_test.cc index acf5fe0..706f809 100644 --- a/leveldb_base/test/ttl_test.cc +++ b/leveldb_base/test/ttl_test.cc @@ -20,11 +20,10 @@ Status OpenDB(std::string dbName, DB **db) { void InsertData(DB *db, uint64_t ttl/* second */) { WriteOptions writeOptions; int key_num = data_size / value_size; - srand(static_cast(time(0))); - //srand(0); + //srand(static_cast(time(0))); + srand(0); for (int i = 0; i < key_num; i++) { - //int key_ = rand() % key_num+1; - int key_ = i + 1; + int key_ = rand() % key_num+1; std::string key = std::to_string(key_); std::string value(value_size, 'a'); db->Put(writeOptions, key, value, ttl); @@ -36,8 +35,8 @@ void GetData(DB *db, int size = (1 << 30)) { int key_num = data_size / value_size; // 点查 - srand(static_cast(time(0))); - //srand(0); + //srand(static_cast(time(0))); + srand(0); for (int i = 0; i < 100; i++) { int key_ = rand() % key_num+1; std::string key = std::to_string(key_); @@ -60,7 +59,8 @@ TEST(TestTTL, ReadTTL) { ReadOptions readOptions; Status status; int key_num = data_size / value_size; - srand(static_cast(time(0))); + //srand(static_cast(time(0))); + srand(0); for (int i = 0; i < 100; i++) { int key_ = rand() % key_num+1; std::string key = std::to_string(key_);