use of com.ms.silverking.time.Stopwatch in project SilverKing by Morgan-Stanley.
the class RingTest method runTest.
public static void runTest(int numWorkers, int n, boolean concurrent) {
RingWorker[] workers;
Semaphore semaphore;
Stopwatch creationSW;
Stopwatch sw;
semaphore = new Semaphore(0);
creationSW = new SimpleStopwatch();
workers = createWorkers(numWorkers, concurrent, semaphore);
creationSW.stop();
System.out.println("Elapsed creation: " + creationSW);
sw = new SimpleStopwatch();
workers[0].addWork(new Integer(n));
try {
semaphore.acquire();
} catch (InterruptedException ie) {
}
sw.stop();
System.out.println("Elapsed thread ring: " + sw);
System.exit(0);
}
use of com.ms.silverking.time.Stopwatch in project SilverKing by Morgan-Stanley.
the class ConcurrentMapTest method runTest.
public void runTest(Sharing sharing, MapType mapType, int threads, int iterations, double putFraction) {
Worker[] workers;
AtomicBoolean start;
Stopwatch sw;
start = new AtomicBoolean(false);
workers = new Worker[threads];
switch(sharing) {
case Global:
Map<Integer, Integer> globalMap;
globalMap = createMap(mapType, threads);
for (int i = 0; i < workers.length; i++) {
workers[i] = new Worker(i, globalMap, iterations, start, putFraction);
}
break;
case PerThread:
for (int i = 0; i < workers.length; i++) {
Map<Integer, Integer> workerMap;
workerMap = createMap(mapType, 1);
workers[i] = new Worker(i, workerMap, iterations, start, putFraction);
}
break;
default:
throw new RuntimeException("panic");
}
sw = new SimpleStopwatch();
start.set(true);
for (int i = 0; i < workers.length; i++) {
workers[i].waitForCompletion();
}
sw.stop();
System.out.println("Complete");
System.out.printf("Global elapsed %.2f\taccesses/s %e\n", sw.getElapsedSeconds(), (double) (iterations * workers.length) / sw.getElapsedSeconds());
for (int i = 0; i < workers.length; i++) {
System.out.printf("Worker %2d elapsed %.2f\taccesses/s %e\n", i, workers[i].getStopwatch().getElapsedSeconds(), (double) iterations / workers[i].getStopwatch().getElapsedSeconds());
}
}
use of com.ms.silverking.time.Stopwatch in project SilverKing by Morgan-Stanley.
the class BulkThroughput method read.
public int read(TestParameters p, List<Double> batchTimes, String context, SynchronousNamespacePerspective<String, byte[]> syncNSP) throws RetrievalException {
int k;
int readSize;
Stopwatch batchSW;
int lastDisplay;
batchSW = new SimpleStopwatch();
readSize = -1;
k = p.minKey;
lastDisplay = p.minKey;
while (k <= p.maxKey - p.batchSize) {
int batchSize;
Map<String, byte[]> values;
Set<String> keys;
byte[] value;
batchSize = Math.min(p.batchSize, p.maxKey - p.minKey + 1);
keys = createSet(context, k, batchSize);
batchSW.reset();
values = syncNSP.get(keys);
batchSW.stop();
if (options.verifyValues) {
verifyValues(keys, values);
}
batchTimes.add(batchSW.getElapsedSeconds());
k += batchSize;
value = values.get(key(context, p.minKey));
if (value != null) {
readSize += value.length;
}
if (options.verbose && k - lastDisplay >= options.displayInterval) {
out.printf("%d\t%s\n", k, new Date());
lastDisplay = k;
}
}
return readSize;
}
use of com.ms.silverking.time.Stopwatch in project SilverKing by Morgan-Stanley.
the class BulkThroughput method runParallelTests.
public void runParallelTests(BulkThroughputOptions options) throws PutException, RetrievalException {
Stopwatch sw;
double iops;
testRunners = new TestRunner[options.parallelThreads];
for (int i = 0; i < options.parallelThreads; i++) {
runParallelTest(options.test, new TestParameters(options.numKeys, options.batchSize, 0, options.numKeys, options.reps), options.externalReps);
}
sw = new SimpleStopwatch();
out.printf("\n *** Starting ***\n");
for (int i = 0; i < options.parallelThreads; i++) {
testRunners[i].start();
}
for (int i = 0; i < options.parallelThreads; i++) {
testRunners[i].waitForCompletion();
}
sw.stop();
long bytes = (long) options.reps * (long) options.numKeys * (long) options.valueSize;
double _Mbps = NetUtil.calcMbps(bytes, sw);
iops = (double) (options.numKeys * options.reps * options.parallelThreads) / sw.getElapsedSeconds();
double timePerKey = 1 / iops;
out.printf("\n *** Aggregate ***\n");
out.printf("Elapsed %s\n", sw);
out.printf("Throughput (Mbps) %f\n", _Mbps);
out.printf("Throughput (IOPS) %f\n", iops);
out.printf("Time / key %f s (%f ms)\n", timePerKey, timePerKey * 1000);
}
use of com.ms.silverking.time.Stopwatch in project SilverKing by Morgan-Stanley.
the class BulkThroughput method write.
public void write(TestParameters p, List<Double> batchTimes, String context, SynchronousNamespacePerspective<String, byte[]> syncNSP) throws PutException {
int k;
int lastDisplay;
Stopwatch batchSW = new SimpleStopwatch();
Map<String, byte[]> keysAndVals;
k = p.minKey;
lastDisplay = p.minKey;
int i = 0;
int batchMultiple = p.maxKey / p.batchSize / 10;
while (k <= p.maxKey - p.batchSize) {
if (i++ % batchMultiple == 0)
System.out.println("batch: " + i);
int batchSize;
batchSize = Math.min(p.batchSize, p.maxKey - k + 1);
// out.printf("put %d\n", k, batchSize);
keysAndVals = createMap(context, k, batchSize);
batchSW.reset();
syncNSP.put(keysAndVals);
batchSW.stop();
batchTimes.add(batchSW.getElapsedSeconds());
k += batchSize;
if (options.verbose && k - lastDisplay > options.displayInterval) {
out.printf("%d\t%s\n", k, new Date());
lastDisplay = k;
}
}
}
Aggregations