summaryrefslogtreecommitdiffstats
path: root/searchlib
diff options
context:
space:
mode:
authorTor Egge <Tor.Egge@broadpark.no>2020-02-13 12:51:21 +0100
committerTor Egge <Tor.Egge@broadpark.no>2020-02-13 12:54:59 +0100
commit9ffd806284f58291a733ae1abd61d71ed15bd3fc (patch)
tree7e989f94b111b4878facebf020e3c570032374f3 /searchlib
parent1e35637ebf9bf87fb12a7e3ab009988b8fe0bf0d (diff)
Use simple standard pseudorandom generator.
Diffstat (limited to 'searchlib')
-rw-r--r--searchlib/src/apps/docstore/benchmarkdatastore.cpp11
1 files changed, 4 insertions, 7 deletions
diff --git a/searchlib/src/apps/docstore/benchmarkdatastore.cpp b/searchlib/src/apps/docstore/benchmarkdatastore.cpp
index 620a139d451..4f8a4ad7345 100644
--- a/searchlib/src/apps/docstore/benchmarkdatastore.cpp
+++ b/searchlib/src/apps/docstore/benchmarkdatastore.cpp
@@ -9,6 +9,7 @@
#include <vespa/vespalib/data/databuffer.h>
#include <vespa/fastos/app.h>
#include <unistd.h>
+#include <random>
#include <vespa/log/log.h>
LOG_SETUP("documentstore.benchmark");
@@ -65,17 +66,13 @@ BenchmarkDataStoreApp::Main()
void BenchmarkDataStoreApp::read(size_t numReads, size_t perChunk, const IDataStore * dataStore)
{
vespalib::DataBuffer buf;
- struct random_data rstate;
- char state[8];
- memset(state, 0, sizeof(state));
- memset(&rstate, 0, sizeof(rstate));
+ std::minstd_rand rng;
const size_t docIdLimit(dataStore->getDocIdLimit());
assert(docIdLimit > 0);
- initstate_r(getpid(), state, sizeof(state), &rstate);
- assert(srandom_r(getpid(), &rstate) == 0);
+ rng.seed(getpid());
int32_t rnd(0);
for ( size_t i(0); i < numReads; i++) {
- random_r(&rstate, &rnd);
+ rnd = rng();
uint32_t lid(rnd%docIdLimit);
for (uint32_t j(lid); j < std::min(docIdLimit, lid+perChunk); j++) {
dataStore->read(j, buf);