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