Permalink
Browse files

Initialize seqno array with rand()

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 e4472b9c67fe6c3ea4b2d617c0ac0bd6912eb5d8
Showing with 21 additions and 2 deletions.
  1. +21 −2 example/pillowfight/pillowfight.cc
@@ -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]);
}
@@ -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;
}
@@ -154,6 +162,7 @@ class Configuration
uint32_t numInstances;
bool timings;
bool loop;
+ uint32_t randomSeed;
} config;
extern "C" {
@@ -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() {
@@ -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)) {
@@ -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);

0 comments on commit e4472b9

Please sign in to comment.