Skip to content

Commit

Permalink
Initialize seqno array with rand()
Browse files Browse the repository at this point in the history
Change-Id: I8e46e48cf3b279c31476887c6d36a704e90c6a9d
Reviewed-on: http://review.couchbase.org/25075
Tested-by: Sergey Avseyev <sergey.avseyev@gmail.com>
Reviewed-by: Trond Norbye <trond.norbye@gmail.com>
  • Loading branch information
avsej authored and trondn committed Mar 11, 2013
1 parent eeb140f commit e4472b9
Showing 1 changed file with 21 additions and 2 deletions.
23 changes: 21 additions & 2 deletions example/pillowfight/pillowfight.cc
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,8 @@ class Configuration
numThreads(1),
numInstances(1),
timings(false),
loop(false) {
// @todo initialize the random sequence in seqno
loop(false),
randomSeed(0) {
data = static_cast<void *>(new char[maxSize]);
}

Expand Down Expand Up @@ -98,6 +98,14 @@ class Configuration
bucket.assign(b);
}

void setRandomSeed(uint32_t val) {
randomSeed = val;
}

uint32_t getRandomSeed() {
return randomSeed;
}

void setIterations(uint32_t val) {
iterations = val;
}
Expand Down Expand Up @@ -154,6 +162,7 @@ class Configuration
uint32_t numInstances;
bool timings;
bool loop;
uint32_t randomSeed;
} config;

extern "C" {
Expand Down Expand Up @@ -262,6 +271,10 @@ class ThreadContext
exit(EXIT_FAILURE);
}
pool = new InstancePool(poolSize, io);
srand(config.getRandomSeed());
for (int ii = 0; ii < 8192; ++ii) {
seqno[ii] = rand();
}
}

~ThreadContext() {
Expand Down Expand Up @@ -482,6 +495,8 @@ static void handle_options(int argc, char **argv)
"Loop running load"));
getopt.addOption(new CommandLineOption('T', "timings", false,
"Enable internal timings"));
getopt.addOption(new CommandLineOption('s', "random-seed", true,
"Specify random seed (default 0)"));
/* getopt.addOption(new CommandLineOption()); */

if (!getopt.parse(argc, argv)) {
Expand Down Expand Up @@ -537,6 +552,10 @@ static void handle_options(int argc, char **argv)
config.setTimings(true);
break;

case 's' :
config.setRandomSeed(atoi((*iter)->argument));
break;

case '?':
getopt.usage(argv[0]);
exit(EXIT_FAILURE);
Expand Down

0 comments on commit e4472b9

Please sign in to comment.