File tree Expand file tree Collapse file tree
affinity/src/main/java/net/openhft/affinity Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -79,10 +79,22 @@ public class MicroJitterSampler {
7979 20 * 1000 * 1000 , 50 * 1000 * 1000 , 100 * 1000 * 1000
8080 };
8181 private static final double UTIL = Double .parseDouble (System .getProperty ("util" , "50" ));
82+ private static final boolean BUSYWAIT = Boolean .parseBoolean (System .getProperty ("busywait" , "false" ));
83+
8284 // static final int CPU = Integer.getInteger("cpu", 0);
8385 private final int [] count = new int [DELAY .length ];
8486 private long totalTime = 0 ;
8587
88+ private static void pause () throws InterruptedException
89+ {
90+ if (BUSYWAIT ) {
91+ long now = System .nanoTime ();
92+ while (System .nanoTime () - now < 1_000_000 );
93+ } else {
94+ Thread .sleep (1 );
95+ }
96+
97+ }
8698 public static void main (String ... ignored ) throws InterruptedException {
8799 // AffinityLock al = AffinityLock.acquireLock();
88100
@@ -98,7 +110,7 @@ public static void main(String... ignored) throws InterruptedException {
98110 for (int i = 0 ; i < 30 * 1000 ; i += 2 ) {
99111 microJitterSampler .sample (sampleLength );
100112 //noinspection BusyWait
101- Thread . sleep ( 1 );
113+ pause ( );
102114 }
103115 }
104116
You can’t perform that action at this time.
0 commit comments