@@ -0,0 +1,3221 @@
+/*%0A *     Copyright (C) 2015  higherfrequencytrading.com%0A *%0A *     This program is free software: you can redistribute it and/or modify%0A *     it under the terms of the GNU Lesser General Public License as published by%0A *     the Free Software Foundation, either version 3 of the License.%0A *%0A *     This program is distributed in the hope that it will be useful,%0A *     but WITHOUT ANY WARRANTY; without even the implied warranty of%0A *     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the%0A *     GNU Lesser General Public License for more details.%0A *%0A *     You should have received a copy of the GNU Lesser General Public License%0A *     along with this program.  If not, see %3Chttp://www.gnu.org/licenses/%3E.%0A */%0A%0Apackage net.openhft.chronicle.core.benchmark;%0A%0Aimport net.openhft.chronicle.core.Jvm;%0Aimport org.openjdk.jmh.annotations.Benchmark;%0Aimport org.openjdk.jmh.annotations.Mode;%0Aimport org.openjdk.jmh.annotations.Scope;%0Aimport org.openjdk.jmh.annotations.State;%0Aimport org.openjdk.jmh.runner.Runner;%0Aimport org.openjdk.jmh.runner.RunnerException;%0Aimport org.openjdk.jmh.runner.options.Options;%0Aimport org.openjdk.jmh.runner.options.OptionsBuilder;%0Aimport org.openjdk.jmh.runner.options.TimeValue;%0A%0Aimport java.lang.reflect.InvocationTargetException;%0Aimport java.lang.reflect.Method;%0Aimport java.util.concurrent.TimeUnit;%0A%0A@State(Scope.Thread)%0Apublic class Interrupted %7B%0A    Thread currentThread = null;%0A    MyThread myThread = new MyThread();%0A%0A    public static void main(String... args) throws RunnerException, InvocationTargetException, IllegalAccessException %7B%0A        if (Jvm.isDebug()) %7B%0A            Interrupted main = new Interrupted();%0A            for (Method m : Interrupted.class.getMethods()) %7B%0A                if (m.getAnnotation(Benchmark.class) != null) %7B%0A                    m.invoke(main);%0A                %7D%0A            %7D%0A        %7D else %7B%0A            int time = Boolean.getBoolean(%22longTest%22) ? 30 : 1;%0A            System.out.println(%22measurementTime: %22 + time + %22 secs%22);%0A            Options opt = new OptionsBuilder()%0A                    .include(Interrupted.class.getSimpleName())%0A                    .warmupIterations(5)%0A                    .measurementIterations(5)%0A                    .forks(5)%0A                    .mode(Mode.SampleTime)%0A                    .measurementTime(TimeValue.seconds(time))%0A                    .timeUnit(TimeUnit.NANOSECONDS)%0A                    .build();%0A%0A            new Runner(opt).run();%0A        %7D%0A    %7D%0A%0A    @Benchmark%0A    public boolean interrupted() %7B%0A        if (currentThread == null)%0A            currentThread = Thread.currentThread();%0A        return currentThread.isInterrupted();%0A    %7D%0A%0A    @Benchmark%0A    public boolean volatileBoolean() %7B%0A        // only included to be like to for like%0A        if (currentThread == null)%0A            currentThread = Thread.currentThread();%0A        // end of dummy code.%0A        return myThread.isInterrupted();%0A    %7D%0A%0A    static class MyThread extends Thread %7B%0A        volatile boolean interrupted;%0A%0A        @Override%0A        public void interrupt() %7B%0A            interrupted = true;%0A        %7D%0A%0A        @Override%0A        public boolean isInterrupted() %7B%0A            return interrupted;%0A        %7D%0A    %7D%0A%7D%0A%0A

Add an Interrupted benchmark