I have been doing some performance testing on Chronicle queue and I am not getting the latency in the micro seconds that Chronicle claims I should. I have a single writer and reader setup. The writer writes the current time into the queue and the reader reads out of the queue and get the current time and does a diff the get the latency. I do this for a million messages and then take the average.
Code for my writer:
public class Client {
public static void main(String[] args) {
String path = "/dev/shm/queue";
SingleChronicleQueue queue = SingleChronicleQueueBuilder.binary(path).build();
ExcerptAppender appender = queue.acquireAppender();
Scanner read = new Scanner(System.in);
for (int i = 0;i<1;i++){
for (int j=0;j<1000000;j++) {
long time = System.nanoTime();
appender.writeText(Long.toString(time));
}
}
appender.writeText("end");
}
}
My reader
public class Server {
public static void main(String[] args) {
String path = "/dev/shm/queue";
SingleChronicleQueue queue = SingleChronicleQueueBuilder.binary(path).build();
ExcerptTailer tailer = queue.createTailer();
DescriptiveStatistics results = new DescriptiveStatistics();
while (true) {
String text = tailer.readText();
if (text == null) {
Jvm.pause(10);
} else if (text.equals("end")) {
System.out.println("Results: " + results.getMean() / 1000);
break;
}
else {
long cur = System.nanoTime();
long recv = Long.parseLong(text);
long diff = cur - recv;
results.addValue(diff);
}
}
}
}
I get latencies in the tens and sometime hundreds of milliseconds. Can any help me with this? I think I am doing something obviously wrong.