Search in sources :

Example 31 with Stopwatch

use of com.ms.silverking.time.Stopwatch in project SilverKing by Morgan-Stanley.

the class PingMultiPong method _runTest.

private void _runTest(int threadID) throws PutException, RetrievalException {
    Stopwatch sw;
    System.out.println("Mode: " + mode);
    sw = new SimpleStopwatch();
    for (int i = 0; i < iterations; i++) {
        String pingKey;
        String pongKeyBase;
        long version;
        version = 0;
        pingKey = "Ping." + i;
        pongKeyBase = "Pong." + i;
        /*
            version = i;
            pingKey = "Ping";
            pongKey = "Pong";
            */
        if (verbose) {
            System.out.println("Iteration");
        }
        switch(mode) {
            case Client:
                clientIteration(pingKey, pongKeyBase, version);
                break;
            case Server:
                serverIteration(pingKey, pongKeyBase, version, threadID);
                break;
            default:
                throw new RuntimeException("panic");
        }
    }
    sw.stop();
    Log.warning("Elapsed:\t" + sw.getElapsedSeconds());
}
Also used : Stopwatch(com.ms.silverking.time.Stopwatch) SimpleStopwatch(com.ms.silverking.time.SimpleStopwatch) SimpleStopwatch(com.ms.silverking.time.SimpleStopwatch) VersionConstraint(com.ms.silverking.cloud.dht.VersionConstraint)

Example 32 with Stopwatch

use of com.ms.silverking.time.Stopwatch in project SilverKing by Morgan-Stanley.

the class PingPongTest method runQueueingConnectionTestClient.

private void runQueueingConnectionTestClient(double durationSeconds, int index) throws IOException {
    ByteBuffer[] msg;
    Stopwatch sw;
    Stopwatch displaySW;
    Semaphore semaphore;
    semaphore = semaphores[index];
    // msg = createMessage(NumConversion.intToBytes(index));
    sw = new SimpleStopwatch();
    displaySW = new SimpleStopwatch();
    do {
        // msg = createMessage(NumConversion.intToBytes(clientPort));
        NumConversion.intToBytes(clientPort, payloadBuffer);
        msg = createMessage(payloadBuffer);
        // System.out.println("Sending");
        messagesSent.incrementAndGet();
        paServer.send(serverAddr, msg, false, Long.MAX_VALUE);
        if (batchMode == BatchMode.PingPong) {
            try {
                semaphore.acquire();
            } catch (InterruptedException ie) {
            }
        }
        // rewindBuffers(msg);
        if (displaySW.getSplitSeconds() > displayIntervalSeconds) {
            displayStats(sw.getSplitSeconds());
            displaySW.reset();
        }
    } while (sw.getSplitSeconds() < durationSeconds);
    if (batchMode == BatchMode.BatchPingPong) {
        try {
            semaphore.acquire(messagesSent.get());
        } catch (InterruptedException ie) {
        }
    }
    sw.stop();
    displayStats(sw.getElapsedSeconds());
}
Also used : Stopwatch(com.ms.silverking.time.Stopwatch) SimpleStopwatch(com.ms.silverking.time.SimpleStopwatch) Semaphore(java.util.concurrent.Semaphore) SimpleStopwatch(com.ms.silverking.time.SimpleStopwatch) ByteBuffer(java.nio.ByteBuffer)

Example 33 with Stopwatch

use of com.ms.silverking.time.Stopwatch in project SilverKing by Morgan-Stanley.

the class LoadTest method runTest.

public void runTest() {
    Stopwatch sw;
    System.out.println("Running test");
    System.out.println(LWTThreadUtil.isLWTThread());
    sw = new SimpleStopwatch();
    for (int i = 0; i < sourceLoadSize; i++) {
        sourceGroup.broadcastWork(i);
    }
    try {
        semaphore.acquire();
    } catch (InterruptedException ie) {
    }
    sw.stop();
    System.out.println("Test complete: " + sw);
    System.exit(0);
}
Also used : SimpleStopwatch(com.ms.silverking.time.SimpleStopwatch) Stopwatch(com.ms.silverking.time.Stopwatch) SimpleStopwatch(com.ms.silverking.time.SimpleStopwatch)

Example 34 with Stopwatch

use of com.ms.silverking.time.Stopwatch in project SilverKing by Morgan-Stanley.

the class IncastTest method main.

public static void main(String[] args) {
    try {
        IncastTest incastTest;
        String gridConfig;
        String host;
        String id;
        Mode mode;
        int numKeys;
        int valueSize;
        int batchSize;
        Stopwatch sw;
        long totalBytes;
        double Bps;
        double bps;
        double Mbps;
        double MBps;
        if (args.length < 6 || args.length > 7) {
            System.out.println("You should probably be using BulkThroughputAnalysis in place of this");
            System.out.println("args: <gridConfig> <host> <id> Write <numKeys> <batchSize>");
            System.out.println("args: <gridConfig> <host> <id> Read <numKeys> <batchSize> <valueSize>");
            return;
        }
        gridConfig = args[0];
        host = args[1];
        id = args[2];
        mode = Mode.valueOf(args[3]);
        numKeys = Integer.parseInt(args[4]);
        batchSize = Integer.parseInt(args[5]);
        LWTPoolProvider.createDefaultWorkPools(DefaultWorkPoolParameters.defaultParameters());
        incastTest = new IncastTest(gridConfig, host, id);
        sw = new SimpleStopwatch();
        switch(mode) {
            case Write:
                valueSize = Integer.parseInt(args[6]);
                totalBytes = incastTest.write(numKeys, batchSize, valueSize);
                break;
            case Read:
                totalBytes = incastTest.read(numKeys, batchSize);
                break;
            default:
                throw new RuntimeException("panic");
        }
        sw.stop();
        Bps = (double) totalBytes / sw.getElapsedSeconds();
        bps = Bps * 8.0;
        Mbps = bps / 1e6;
        MBps = Bps / 1e6;
        Log.warning("Elapsed:\t" + sw.getElapsedSeconds());
        Log.warning("totalBytes:\t" + totalBytes);
        Log.warning("bps:\t" + bps);
        Log.warning("Bps:\t" + Bps);
        Log.warning("Mbps:\t" + Mbps);
        Log.warning("MBps:\t" + MBps);
    } catch (Exception e) {
        e.printStackTrace();
    }
}
Also used : NamespaceVersionMode(com.ms.silverking.cloud.dht.NamespaceVersionMode) Stopwatch(com.ms.silverking.time.Stopwatch) SimpleStopwatch(com.ms.silverking.time.SimpleStopwatch) SimpleStopwatch(com.ms.silverking.time.SimpleStopwatch) PutException(com.ms.silverking.cloud.dht.client.PutException) ClientException(com.ms.silverking.cloud.dht.client.ClientException) IOException(java.io.IOException) RetrievalException(com.ms.silverking.cloud.dht.client.RetrievalException)

Example 35 with Stopwatch

use of com.ms.silverking.time.Stopwatch in project SilverKing by Morgan-Stanley.

the class ObjectUtil method main.

public static void main(String[] args) {
    try {
        String testString;
        int reps;
        Stopwatch sw;
        String s;
        byte[] b;
        if (args.length < 2) {
            System.out.println("<string> <reps>");
            return;
        }
        testString = args[0];
        reps = Integer.parseInt(args[1]);
        sw = new SimpleStopwatch();
        s = null;
        b = null;
        for (int i = 0; i < reps; i++) {
            b = objToBytes(testString);
            s = (String) bytesToObj(b);
        }
        sw.stop();
        if (!s.equals(testString)) {
            throw new RuntimeException("verify failed");
        }
        System.out.println(sw.getElapsedSeconds() / (double) reps);
        System.out.println(b.length);
        b = objToBytesWithSize(testString);
        System.out.println(b.length);
        s = (String) bytesToObjIgnoreSize(b);
        if (!s.equals(testString)) {
            throw new RuntimeException("verify failed");
        }
    } catch (Exception e) {
        e.printStackTrace();
    }
}
Also used : SimpleStopwatch(com.ms.silverking.time.SimpleStopwatch) Stopwatch(com.ms.silverking.time.Stopwatch) SimpleStopwatch(com.ms.silverking.time.SimpleStopwatch) IOException(java.io.IOException)

Aggregations

Stopwatch (com.ms.silverking.time.Stopwatch)42 SimpleStopwatch (com.ms.silverking.time.SimpleStopwatch)41 VersionConstraint (com.ms.silverking.cloud.dht.VersionConstraint)7 IOException (java.io.IOException)5 ByteBuffer (java.nio.ByteBuffer)5 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 SimpleTimer (com.ms.silverking.time.SimpleTimer)2 Timer (com.ms.silverking.time.Timer)2 FileOutputStream (java.io.FileOutputStream)2 Date (java.util.Date)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 SessionOptions (com.ms.silverking.cloud.dht.SessionOptions)1