use of com.ms.silverking.time.SimpleStopwatch 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());
}
use of com.ms.silverking.time.SimpleStopwatch 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());
}
use of com.ms.silverking.time.SimpleStopwatch 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());
}
use of com.ms.silverking.time.SimpleStopwatch 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);
}
use of com.ms.silverking.time.SimpleStopwatch in project SilverKing by Morgan-Stanley.
the class NumConversion method main.
// ///////////
public static void main(String[] args) {
int i;
byte[] b;
// i = Integer.parseInt(args[0]);
// b = new byte[BYTES_PER_INT];
// intToBytes(i, b);
// System.out.println( ">>"+ bytesToInt(b) );
// benchmark test
byte[] bytes = { Byte.MIN_VALUE, Byte.MAX_VALUE, Byte.MIN_VALUE, Byte.MAX_VALUE, Byte.MIN_VALUE, Byte.MAX_VALUE, Byte.MIN_VALUE, Byte.MAX_VALUE };
SimpleTimer timer = new SimpleTimer(TimeUnit.SECONDS, 3);
timer.reset();
timer.stop();
timer.start();
while (!timer.hasExpired()) System.out.println(timer.getSplitSeconds());
//
// // timer = new SimpleTimer(TimeUnit.SECONDS, 3);
// // timer.reset();
// // while (!timer.hasExpired())
// // System.out.println(timer.getSplitSeconds());
//
SimpleStopwatch watch = new SimpleStopwatch();
watch.reset();
for (int j = 0; j < 1_000_000_000; j++) bytesToLong(bytes);
watch.stop();
System.out.println("Time for inline: " + watch.getElapsedMillis());
watch.reset();
for (int j = 0; j < 1_000_000_000; j++) bytesToLong2(bytes);
watch.stop();
System.out.println("Time for wrapped: " + watch.getElapsedMillis());
// SimpleTimer timer = new SimpleTimer(TimeUnit.MILLISECONDS, 1_000_000_000);
// timer.stop();
// // timer.reset();
// timer.start();
// for (int j = 0; j < 1_000_000; j++)
// bytesToLong(bytes);
// timer.stop();
//
// System.out.println("Time for inline: " + timer.getElapsedMillis());
//
// timer.start();
// for (int j = 0; j < 1_000_000; j++)
// bytesToLong2(bytes);
// timer.stop();
//
// System.out.println("Time for wrapped: " + timer.getElapsedMillis());
}
Aggregations