package net.openhft.chronicle.core.latencybenchmark;

import net.openhft.chronicle.core.Jvm;
import net.openhft.chronicle.core.util.NanoSampler;

/**
 * Created by daniel on 08/03/2016.
 */
public class ExampleLatencyMain implements LatencyTask {
    int count = 0;
    private LatencyTestHarness lth;
    private NanoSampler nanoSamplerSin;
    private NanoSampler nanoSamplerWait;

    public static void main(String[] args) {
        LatencyTestHarness lth = new LatencyTestHarness()
                .warmUp(500_000)
                .messageCount(20_000)
                .throughput(25_000)
                .accountForCoordinatedOmmission(true)
                .runs(7)
                .build(new ExampleLatencyMain());
        lth.start();
    }

    double sin;
    @Override
    public void run(long startTimeNS) {
        count++;
        if(count%200==0) {
            long now = System.nanoTime();
            Jvm.busyWaitMicros(1);
            nanoSamplerWait.sampleNanos(System.nanoTime()-now);
        }

        long now = System.nanoTime();
        sin = Math.sin(count);
        nanoSamplerSin.sampleNanos(System.nanoTime()-now);

        lth.sample(System.nanoTime()-startTimeNS);
    }

    @Override
    public void init(LatencyTestHarness lth) {

        this.lth = lth;
        nanoSamplerSin = lth.createAdditionalSampler("sin");
        nanoSamplerWait = lth.createAdditionalSampler("busyWait");
    }

    @Override
    public void complete() {
    }
}

@@ -295,24 +295,26 @@
 ss lth;%0A    
+//
 private Nano
@@ -337,24 +337,26 @@
 lerSin;%0A    
+//
 private Nano
@@ -510,17 +510,16 @@
 armUp(50
-0
 _000)%0A  
@@ -546,17 +546,18 @@
 geCount(
-2
+10
 0_000)%0A 
@@ -671,9 +671,63 @@
 uns(
-7
+3)%0A                .accountForCoordinatedOmmission(true
 )%0A  
@@ -909,14 +909,16 @@
 ount
-%25200==
+==160_00
 0) %7B
@@ -922,32 +922,75 @@
 ) %7B%0A            
+System.out.println(%22PAUSE%22);%0A            //
 long now = Syste
@@ -1023,24 +1023,18 @@
 Jvm.
-busyWaitMicros(1
+pause(1000
 );%0A 
@@ -1036,32 +1036,34 @@
 0);%0A            
+//
 nanoSamplerWait.
@@ -1178,32 +1178,34 @@
 count);%0A        
+//
 nanoSamplerSin.s
@@ -1384,32 +1384,34 @@
  = lth;%0A        
+//
 nanoSamplerSin =
@@ -1455,16 +1455,18 @@
         
+//
 nanoSamp

Allow for 5 digit number fields