Skip to content

Instantly share code, notes, and snippets.

@danielshaya
Created April 15, 2016 11:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save danielshaya/ff6ef8d47273d230eb72b18becdc301d to your computer and use it in GitHub Desktop.
Save danielshaya/ff6ef8d47273d230eb72b18becdc301d to your computer and use it in GitHub Desktop.
package org.latency.spike;
import net.openhft.chronicle.core.Jvm;
import net.openhft.chronicle.core.jlbh.JLBH;
import net.openhft.chronicle.core.jlbh.JLBHOptions;
import net.openhft.chronicle.core.jlbh.JLBHTask;
/**
* A simple JLBH example to show the effects od accounting for co-ordinated omission.
* Toggle the accountForCoordinatedOmission to see results.
*/
public class SimpleSpikeJLBHTask implements JLBHTask {
private int count = 0;
private JLBH lth;
public static void main(String[] args){
JLBHOptions lth = new JLBHOptions()
.warmUpIterations(40_000)
.iterations(1_100_000)
.throughput(100_000)
.runs(3)
.recordOSJitter(true)
.accountForCoordinatedOmmission(true)
.jlbhTask(new SimpleSpikeJLBHTask());
new JLBH(lth).start();
}
@Override
public void run(long startTimeNS) {
if((count++)%10_000==0){
//pause a while
Jvm.busyWaitMicros(1000);
}
lth.sample(System.nanoTime() - startTimeNS);
}
@Override
public void init(JLBH lth) {
this.lth = lth;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment