Search in sources :

Example 1 with Stopwatch

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

the class TimeTest method time.

public static void time() {
    Stopwatch swSystem;
    Stopwatch swNanos;
    Stopwatch swTimerDriven;
    Stopwatch swTimerDrivenDirect;
    TimerDrivenTimeSource ts;
    int reps = 1000000;
    long result;
    TimeTest timeTest;
    RelNanosTimeSource relNanosTimeSource;
    AbsMillisTimeSource absMillisTimeSource;
    absMillisTimeSource = new SystemTimeSource();
    timeTest = new TimeTest();
    result = 0;
    swSystem = new SimpleNamedStopwatch("System");
    for (int i = 0; i < reps; i++) {
        // result += System.currentTimeMillis();
        result += absMillisTimeSource.absTimeMillis();
    }
    swSystem.stop();
    swNanos = new SimpleNamedStopwatch("Nanos");
    for (int i = 0; i < reps; i++) {
        result += System.nanoTime();
    }
    swNanos.stop();
    relNanosTimeSource = new TimerDrivenTimeSource();
    swTimerDriven = new SimpleNamedStopwatch("TimerDriven");
    for (int i = 0; i < reps; i++) {
        // System.out.println(timeTest.getElapsed());
        result += relNanosTimeSource.relTimeNanos();
    }
    swTimerDriven.stop();
    ts = new TimerDrivenTimeSource();
    swTimerDrivenDirect = new SimpleNamedStopwatch("TimerDrivenDirect");
    for (int i = 0; i < reps; i++) {
        // System.out.println(timeTest.getElapsed());
        result += ts.relTimeNanos();
    }
    swTimerDrivenDirect.stop();
    System.out.println(result + "\n");
    displayRate(swSystem, reps);
    displayRate(swNanos, reps);
    displayRate(swTimerDriven, reps);
    displayRate(swTimerDrivenDirect, reps);
}
Also used : TimerDrivenTimeSource(com.ms.silverking.time.TimerDrivenTimeSource) SimpleNamedStopwatch(com.ms.silverking.time.SimpleNamedStopwatch) Stopwatch(com.ms.silverking.time.Stopwatch) SimpleNamedStopwatch(com.ms.silverking.time.SimpleNamedStopwatch) SystemTimeSource(com.ms.silverking.time.SystemTimeSource) AbsMillisTimeSource(com.ms.silverking.time.AbsMillisTimeSource) RelNanosTimeSource(com.ms.silverking.time.RelNanosTimeSource)

Example 2 with Stopwatch

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

the class AsyncPingPong method runTest.

public void runTest() throws PutException, RetrievalException {
    Stopwatch sw;
    System.out.println("Mode: " + mode);
    sw = new SimpleStopwatch();
    for (int i = 0; i < iterations; i++) {
        String pingKey;
        String pongKey;
        long version;
        version = 0;
        pingKey = "Ping." + i;
        pongKey = "Pong." + i;
        /*
            version = i;
            pingKey = "Ping";
            pongKey = "Pong";
            */
        if (verbose) {
            System.out.println("Iteration");
        }
        switch(mode) {
            case Client:
                clientIteration(pingKey, pongKey, version);
                break;
            case Server:
                serverIteration(pingKey, pongKey, version);
                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 3 with Stopwatch

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

the class AsyncPingMultiPong method _runTest.

private void _runTest(int threadID) throws OperationException {
    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 4 with Stopwatch

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

the class PingPong method runTest.

public void runTest() throws PutException, RetrievalException {
    Stopwatch sw;
    System.out.println("Mode: " + mode);
    sw = new SimpleStopwatch();
    for (int i = 0; i < iterations; i++) {
        String pingKey;
        String pongKey;
        long version;
        version = 0;
        pingKey = "Ping." + i;
        pongKey = "Pong." + i;
        /*
            version = i;
            pingKey = "Ping";
            pongKey = "Pong";
            */
        if (verbose) {
            System.out.println("Iteration");
        }
        switch(mode) {
            case Client:
                clientIteration(pingKey, pongKey, version);
                break;
            case Server:
                serverIteration(pingKey, pongKey, version);
                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 5 with Stopwatch

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

the class ByteBufferNetTest method runClient.

public void runClient(HostAndPort serverAddr, double duration) {
    Stopwatch sw;
    ByteBuffer[] data;
    data = createData();
    sw = new SimpleStopwatch();
    do {
        // UUIDBase    uuid;
        // uuid = new UUIDBase();
        Log.info("Sending");
        try {
            paServer.sendAsynchronous(serverAddr.toInetSocketAddress(), data, uuid, this, Long.MAX_VALUE);
        } catch (UnknownHostException uhe) {
            throw new RuntimeException(uhe);
        }
        Log.info("Sent. Waiting for receive");
        try {
            semaphore.acquire();
        } catch (InterruptedException ie) {
        }
    } while (sw.getSplitSeconds() < duration);
}
Also used : UnknownHostException(java.net.UnknownHostException) Stopwatch(com.ms.silverking.time.Stopwatch) SimpleStopwatch(com.ms.silverking.time.SimpleStopwatch) SimpleStopwatch(com.ms.silverking.time.SimpleStopwatch) ByteBuffer(java.nio.ByteBuffer)

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