Skip to content

Instantly share code, notes, and snippets.

View franz1981's full-sized avatar
🏠
Working from home

Francesco Nigro franz1981

🏠
Working from home
View GitHub Profile
private static final MethodHandle SET_ARRAY;
private static final MethodHandle GET_ARRAY;
static {
MethodHandle mh = null;
try {
final Method setArray = CopyOnWriteArrayList.class.getDeclaredMethod("setArray", Object[].class);
if (!setArray.isAccessible()) {
setArray.setAccessible(true);
}
package red.hat.puzzles.benchmarks;
import org.openjdk.jmh.annotations.*;
import org.openjdk.jmh.infra.Blackhole;
import java.util.HashMap;
import java.util.Map;
import java.util.concurrent.TimeUnit;
@State(Scope.Benchmark)
// class version 52.0 (52)
// access flags 0x21
public class red/hat/puzzles/benchmarks/SwitchMapBench {
// compiled from: SwitchMapBench.java
@Lorg/openjdk/jmh/annotations/State;(value=Lorg/openjdk/jmh/annotations/Scope;.Benchmark)
@Lorg/openjdk/jmh/annotations/BenchmarkMode;(value={Lorg/openjdk/jmh/annotations/Mode;.AverageTime})
package red.hat.puzzles.benchmarks;
import org.openjdk.jmh.annotations.*;
import org.openjdk.jmh.infra.Blackhole;
import java.util.HashMap;
import java.util.Map;
import java.util.concurrent.TimeUnit;
@State(Scope.Benchmark)
package red.hat.puzzles.benchmarks;
import org.openjdk.jmh.annotations.*;
import org.openjdk.jmh.infra.Blackhole;
import org.openjdk.jmh.runner.Runner;
import org.openjdk.jmh.runner.RunnerException;
import org.openjdk.jmh.runner.options.Options;
import org.openjdk.jmh.runner.options.OptionsBuilder;
import java.util.HashMap;
private AtomicChunk<E> appendNextChunks(AtomicChunk<E> producerBuffer, long chunkIndex, int chunkSize, long chunks)
{
assert chunkIndex != AtomicChunk.NIL_CHUNK_INDEX;
//prevent other concurrent attempts on appendNextChunk
if (!casProducerChunkIndex(chunkIndex, ROTATION))
{
return null;
}
AtomicChunk<E> newChunk = null;
for (long i = 1; i <= chunks; i++)
static final int SPIN = 10;
@Override
public E waitPoll(MessagePassingQueue<E> q) throws InterruptedException
{
E e = null;
//use counted loop to reduce latencies saving safepoint polls
for (int i = 0; i < SPIN; i++) {
e = q.relaxedPoll();
public class NonFinalHell {
private static final class SimpleString {
byte[] c = new byte[10];
}
static SimpleString ss = new SimpleString();
@CompilerControl(CompilerControl.Mode.DONT_INLINE)
public static int checkNull() {
import org.openjdk.jmh.annotations.*;
import java.util.concurrent.TimeUnit;
@State(Scope.Benchmark)
@BenchmarkMode(Mode.AverageTime)
@OutputTimeUnit(TimeUnit.NANOSECONDS)
@Warmup(iterations = 5, time = 200, timeUnit = TimeUnit.MILLISECONDS)
@Measurement(iterations = 5, time = 200, timeUnit = TimeUnit.MILLISECONDS)
@Fork(1)
import org.openjdk.jmh.annotations.*;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.concurrent.TimeUnit;
@State(Scope.Benchmark)
@BenchmarkMode(Mode.AverageTime)
@OutputTimeUnit(TimeUnit.NANOSECONDS)