Search in sources :

Example 6 with SimpleStopwatch

use of com.ms.silverking.time.SimpleStopwatch 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);
}
Also used : SimpleStopwatch(com.ms.silverking.time.SimpleStopwatch) Stopwatch(com.ms.silverking.time.Stopwatch) Semaphore(java.util.concurrent.Semaphore) SimpleStopwatch(com.ms.silverking.time.SimpleStopwatch)

Example 7 with SimpleStopwatch

use of com.ms.silverking.time.SimpleStopwatch 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());
    }
}
Also used : AtomicBoolean(java.util.concurrent.atomic.AtomicBoolean) SimpleStopwatch(com.ms.silverking.time.SimpleStopwatch) Stopwatch(com.ms.silverking.time.Stopwatch) SimpleStopwatch(com.ms.silverking.time.SimpleStopwatch)

Example 8 with SimpleStopwatch

use of com.ms.silverking.time.SimpleStopwatch 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;
}
Also used : Stopwatch(com.ms.silverking.time.Stopwatch) SimpleStopwatch(com.ms.silverking.time.SimpleStopwatch) SimpleStopwatch(com.ms.silverking.time.SimpleStopwatch) Date(java.util.Date)

Example 9 with SimpleStopwatch

use of com.ms.silverking.time.SimpleStopwatch 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);
}
Also used : Stopwatch(com.ms.silverking.time.Stopwatch) SimpleStopwatch(com.ms.silverking.time.SimpleStopwatch) SimpleStopwatch(com.ms.silverking.time.SimpleStopwatch)

Example 10 with SimpleStopwatch

use of com.ms.silverking.time.SimpleStopwatch 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;
        }
    }
}
Also used : Stopwatch(com.ms.silverking.time.Stopwatch) SimpleStopwatch(com.ms.silverking.time.SimpleStopwatch) SimpleStopwatch(com.ms.silverking.time.SimpleStopwatch) Date(java.util.Date)

Aggregations

SimpleStopwatch (com.ms.silverking.time.SimpleStopwatch)42 Stopwatch (com.ms.silverking.time.Stopwatch)41 VersionConstraint (com.ms.silverking.cloud.dht.VersionConstraint)7 IOException (java.io.IOException)5 ByteBuffer (java.nio.ByteBuffer)5 SimpleTimer (com.ms.silverking.time.SimpleTimer)3 DHTSession (com.ms.silverking.cloud.dht.client.DHTSession)2 DHTKeyIntEntry (com.ms.silverking.cloud.dht.collection.DHTKeyIntEntry)2 DHTKey (com.ms.silverking.cloud.dht.common.DHTKey)2 StatSeries (com.ms.silverking.numeric.StatSeries)2 Timer (com.ms.silverking.time.Timer)2 FileOutputStream (java.io.FileOutputStream)2 Date (java.util.Date)2 Map (java.util.Map)2 Random (java.util.Random)2 ImmutableMap (com.google.common.collect.ImmutableMap)1 GetOptions (com.ms.silverking.cloud.dht.GetOptions)1 NamespaceOptions (com.ms.silverking.cloud.dht.NamespaceOptions)1 NamespaceVersionMode (com.ms.silverking.cloud.dht.NamespaceVersionMode)1 PutOptions (com.ms.silverking.cloud.dht.PutOptions)1