@@ -0,0 +1,3071 @@
+/*%0A * Copyright (c) 2011-2016 Pivotal Software Inc, All Rights Reserved.%0A *%0A * Licensed under the Apache License, Version 2.0 (the %22License%22);%0A * you may not use this file except in compliance with the License.%0A * You may obtain a copy of the License at%0A *%0A *       http://www.apache.org/licenses/LICENSE-2.0%0A *%0A * Unless required by applicable law or agreed to in writing, software%0A * distributed under the License is distributed on an %22AS IS%22 BASIS,%0A * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.%0A * See the License for the specific language governing permissions and%0A * limitations under the License.%0A */%0Apackage reactivestreams.commons.publisher;%0A%0Aimport java.util.concurrent.ExecutorService;%0Aimport java.util.concurrent.Executors;%0Aimport java.util.concurrent.TimeUnit;%0A%0Aimport org.openjdk.jmh.annotations.Benchmark;%0Aimport org.openjdk.jmh.annotations.BenchmarkMode;%0Aimport org.openjdk.jmh.annotations.Fork;%0Aimport org.openjdk.jmh.annotations.Measurement;%0Aimport org.openjdk.jmh.annotations.Mode;%0Aimport org.openjdk.jmh.annotations.OutputTimeUnit;%0Aimport org.openjdk.jmh.annotations.Param;%0Aimport org.openjdk.jmh.annotations.Scope;%0Aimport org.openjdk.jmh.annotations.Setup;%0Aimport org.openjdk.jmh.annotations.State;%0Aimport org.openjdk.jmh.annotations.TearDown;%0Aimport org.openjdk.jmh.annotations.Warmup;%0Aimport org.openjdk.jmh.infra.Blackhole;%0Aimport org.reactivestreams.Publisher;%0A%0Aimport reactivestreams.commons.publisher.internal.PerfAsyncSubscriber;%0Aimport reactivestreams.commons.util.ExecutorServiceScheduler;%0Aimport reactivestreams.commons.util.SpscArrayQueue;%0A%0A%0A/**%0A * Example benchmark. Run from command line as%0A * %3Cbr%3E%0A * gradle jmh -Pjmh='CrossRangeFlatMapObserveOnPerf'%0A */%0A@BenchmarkMode(Mode.Throughput)%0A@Warmup(iterations = 5)%0A@Measurement(iterations = 5, time = 1, timeUnit = TimeUnit.SECONDS)%0A@OutputTimeUnit(TimeUnit.SECONDS)%0A@Fork(value = 1)%0A@State(Scope.Thread)%0Apublic class CrossRangeFlatMapObserveOnPerf %7B%0A    %0A    @Param(%7B%221%22, %221000%22, %221000000%22%7D)%0A    public int count;%0A    %0A    Publisher%3CInteger%3E source1;%0A%0A    Publisher%3CInteger%3E source2;%0A%0A    ExecutorService exec;%0A    %0A    @Setup%0A    public void setup() %7B%0A        exec = Executors.newSingleThreadExecutor();%0A        %0A        ExecutorServiceScheduler scheduler = new ExecutorServiceScheduler(exec);%0A%0A        PublisherBase%3CInteger%3E source = PublisherBase.range(1, count).flatMap(v -%3E PublisherBase.range(v, 2));%0A%0A        source1 = source.observeOn(scheduler);%0A        %0A        source2 = new PublisherObserveOn%3C%3E(source, scheduler, false, 256, () -%3E new SpscArrayQueue%3C%3E(256));%0A    %7D%0A    %0A    @TearDown%0A    public void tearDown() %7B%0A        exec.shutdown();%0A    %7D%0A    %0A    @Benchmark%0A    public void benchDefault(Blackhole bh) %7B%0A        PerfAsyncSubscriber s = new PerfAsyncSubscriber(bh);%0A        %0A        source1.subscribe(s);%0A        %0A        s.await(count);%0A    %7D%0A%0A    @Benchmark%0A    public void benchSpsc(Blackhole bh) %7B%0A        PerfAsyncSubscriber s = new PerfAsyncSubscriber(bh);%0A        %0A        source2.subscribe(s);%0A        %0A        s.await(count);%0A    %7D%0A%7D%0A

Add Cross Range + Async benchmark