mirror of
https://github.com/OpenHFT/Chronicle-Map.git
synced 2021-09-13 01:26:12 +00:00
Adding multiple clients to configurable test
This commit is contained in:
@@ -25,6 +25,7 @@ import net.openhft.lang.values.LongValue;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.Arrays;
|
||||
|
||||
public class DistributedSequenceMain {
|
||||
|
||||
@@ -35,18 +36,47 @@ public class DistributedSequenceMain {
|
||||
.entries(128)
|
||||
.actualSegments(1)
|
||||
.createPersistedTo(file)) {
|
||||
// throughput test.
|
||||
for (int t = 0; t < 5; t++) {
|
||||
LongValue value = DataValueClasses.newDirectReference(LongValue.class);
|
||||
map.acquireUsing("sequence-" + t, value);
|
||||
|
||||
long start = System.nanoTime();
|
||||
int runs = 10000000;
|
||||
int runs = 1000000;
|
||||
for (int i = 0; i < runs; i++) {
|
||||
long nextId = value.addAtomicValue(1);
|
||||
}
|
||||
double rate = (double) (System.nanoTime() - start) / runs;
|
||||
System.out.printf("Uncontended increment took an average of %.1f ns.%n", rate);
|
||||
}
|
||||
|
||||
// latency test.
|
||||
LongValue value = DataValueClasses.newDirectReference(LongValue.class);
|
||||
map.acquireUsing("sequence-X", value);
|
||||
|
||||
int runs = 1000000000, count = 0, wcount = 0;
|
||||
long[] worst = new long[200000];
|
||||
long start = System.nanoTime();
|
||||
for (; count < runs; count++) {
|
||||
long nextId = value.addAtomicValue(1);
|
||||
long next = System.nanoTime();
|
||||
long time = next - start;
|
||||
if (time > 100) {
|
||||
worst[wcount++] = time;
|
||||
if (wcount >= worst.length)
|
||||
break;
|
||||
next = System.nanoTime();
|
||||
}
|
||||
start = next;
|
||||
}
|
||||
Arrays.sort(worst);
|
||||
System.out.printf("Worst 1 in 10K, 1 in 100K, 1 in 1000K, worst is %,d / %,d / %,d / %,d %n",
|
||||
worst[wcount - count / 10000],
|
||||
worst[wcount - count / 100000],
|
||||
worst[wcount - count / 1000000],
|
||||
worst[wcount - 1]
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user