Skip to content

Instantly share code, notes, and snippets.

public void meSoHotInline_avgt_jmhStub(InfraControl control, RawResults result,
SafepointProfiling_jmhType l_safepointprofiling0_0, Blackhole_jmhType l_blackhole1_1) throws Throwable {
long operations = 0;
long realTime = 0;
result.startTime = System.nanoTime();
do {
l_safepointprofiling0_0.meSoHotInline(); /* LINE 163 */
operations++;
// SP poll, uncounted loop
} while (!control.isDone); /* LINE 165 */
@Param("1000")
int size;
byte[] buffer;
boolean result;
@Setup
public final void setup() {
buffer = new byte[size];
}
// 1. counted = reps is int/short/byte
for (int i = 0; i < reps; i++) {
// You had plenty money, 1922
}
// 2. Not counted
for (int i = 0; i < int_reps; i+=2) {
// You let other women make a fool of you
}
public class WhenWillItExitInt3 {
public static void main(String[] argc) throws InterruptedException {
for (int i=0;i<100000;i++) {
countOdds(10);
}
Thread t = new Thread(() -> {
long l = countOdds(Integer.MAX_VALUE);
System.out.println("How Odd:" + l);
});
t.setDaemon(true);
private static long countOdds(int limit) {
long l = 0;
for (int i = 0; i < limit; i++) {
for (int j = 0; j < limit; j++) {
if ((j & 1) == 1)
l++;
}
}
return l;
}
ECLIPSE | JAVAC
int i = 0; | int i = 0;
long l = 0; | long l = 0;
int j; | int j;
goto LOOP_I; | LOOP_OUTER:
OUTER: | if(i >= Integer.MAX_VALUE)
j=0; | goto EXIT_OUTER;
goto LOOP_J; |
| j=0;
INNER: | LOOP_INNER:
@nitsanw
nitsanw / a.class
Last active January 23, 2016 17:25
Bytecode diff of loop
ECLIPSE | JAVAC
0: lconst_0 | 0: lconst_0
1: lstore_0 | 1: lstore_0
2: iconst_0 | 2: iconst_0
3: istore_2 | 3: istore_2
|
4: goto 35 | 4: iload_2
7: iconst_0 | 5: ldc #11 // int 2147483647
8: istore_3 | 7: if_icmpge 41 // i >= INT_MAX goto 41
9: goto 26 | 10: iconst_0
package safepoint.hang;
public class WhenWillItExitInt {
public static void main(String[] argc) throws InterruptedException {
Thread t = new Thread(() -> {
long l = 0;
for (int i = 0; i < Integer.MAX_VALUE; i++) {
for (int j = 0; j < Integer.MAX_VALUE; j++) {
if ((j & 1) == 1)
l++;
}
@Param({ "0" })
int idleThreads;
Thread[] pool;
@Setup
public final void bakeACake() {
if (idleThreads != 0) {
pool = new Thread[idleThreads];
for (int i = 0; i < idleThreads; i++) {
pool[i] = new Thread(() -> {
@State(Scope.Thread)
@BenchmarkMode(Mode.AverageTime)
@OutputTimeUnit(TimeUnit.NANOSECONDS)
public class ArrayWrapperInterfaceBenchmark {
@Param({ "100", "1000", "10000" })
public int size;
private DataSet datasetA;
private DataSet datasetB;
private static final class DataSet {