[thin] Adopt stateful random number generators

This commit is contained in:
Ming-Hung Tsai
2020-08-04 11:45:36 +08:00
parent 06dfb976c2
commit 3f19818c56
3 changed files with 39 additions and 9 deletions

View File

@@ -1,3 +1,5 @@
#include <chrono>
#include <random>
#include "damage_generator.h"
using namespace thin_provisioning;
@@ -13,12 +15,14 @@ namespace {
base::run_set<block_address> visited;
block_address nr_visited = 0;
srand(time(NULL));
uint64_t rand_seed(std::chrono::high_resolution_clock::now().time_since_epoch().count());
std::mt19937 rand_engine(rand_seed);
while (nr_blocks) {
if (nr_visited == sm_size)
break;
block_address b = rand() % sm_size;
block_address b = rand_engine() % sm_size;
if (visited.member(b))
continue;