Skip to content

Commit 227ae9b

Browse files
[tests] Use FastRandomContext instead of boost::random::{mt19937,uniform_int_distribution}
1 parent 1b708f2 commit 227ae9b

File tree

1 file changed

+4
-6
lines changed

1 file changed

+4
-6
lines changed

src/test/scheduler_tests.cpp

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,6 @@
88
#include "test/test_bitcoin.h"
99

1010
#include <boost/bind.hpp>
11-
#include <boost/random/mersenne_twister.hpp>
12-
#include <boost/random/uniform_int_distribution.hpp>
1311
#include <boost/thread.hpp>
1412
#include <boost/test/unit_test.hpp>
1513

@@ -56,10 +54,10 @@ BOOST_AUTO_TEST_CASE(manythreads)
5654

5755
boost::mutex counterMutex[10];
5856
int counter[10] = { 0 };
59-
boost::random::mt19937 rng(42);
60-
boost::random::uniform_int_distribution<> zeroToNine(0, 9);
61-
boost::random::uniform_int_distribution<> randomMsec(-11, 1000);
62-
boost::random::uniform_int_distribution<> randomDelta(-1000, 1000);
57+
FastRandomContext rng(42);
58+
auto zeroToNine = [](FastRandomContext& rc) -> int { return rc.randrange(10); }; // [0, 9]
59+
auto randomMsec = [](FastRandomContext& rc) -> int { return -11 + rc.randrange(1012); }; // [-11, 1000]
60+
auto randomDelta = [](FastRandomContext& rc) -> int { return -1000 + rc.randrange(2001); }; // [-1000, 1000]
6361

6462
boost::chrono::system_clock::time_point start = boost::chrono::system_clock::now();
6563
boost::chrono::system_clock::time_point now = start;

0 commit comments

Comments
 (0)