package com.github.davidmoten.rx;

import org.openjdk.jmh.annotations.Benchmark;

import rx.Observable;
import rx.functions.Func2;

import com.github.davidmoten.rx.operators.OperatorTakeLastOne;

public class Benchmarks {

    private static final int MANY = 1000000;
    private static final int FEW = 5;

    @Benchmark
    public void takeLastOneFromRxJavaLibrary() {
        Observable.range(1, MANY).takeLast(1).subscribe();
    }

    @Benchmark
    public void takeLastOneFromRxJavaLibraryFew() {
        Observable.range(1, FEW).takeLast(1).subscribe();
    }

    @Benchmark
    public void takeLastOneFromExtras() {
        Observable.range(1, MANY).lift(OperatorTakeLastOne.<Integer> create()).subscribe();
    }

    @Benchmark
    public void takeLastOneFromExtrasFew() {
        Observable.range(1, FEW).lift(OperatorTakeLastOne.<Integer> create()).subscribe();
    }

    private static final Func2<Integer, ? super Integer, Integer> COUNT = new Func2<Integer, Integer, Integer>() {

        @Override
        public Integer call(Integer count, Integer o) {
            return count + 1;
        }
    };

}

@@ -261,16 +261,57 @@
 000000;%0A
+    private static final int SOME = 100;%0A
     priv
@@ -340,16 +340,16 @@
 EW = 5;%0A
-
 %0A    @Be
@@ -595,32 +595,166 @@
 cribe();%0A    %7D%0A%0A
+    @Benchmark%0A    public void takeLastOneFromRxJavaLibrarySome() %7B%0A        Observable.range(1, SOME).takeLast(1).subscribe();%0A    %7D%0A%0A
     @Benchmark%0A 
@@ -945,32 +945,32 @@
 omExtrasFew() %7B%0A
-
         Observab
@@ -1047,24 +1047,184 @@
 e();%0A    %7D%0A%0A
+    @Benchmark%0A    public void takeLastOneFromExtrasSome() %7B%0A        Observable.range(1, SOME).lift(OperatorTakeLastOne.%3CInteger%3E create()).subscribe();%0A    %7D%0A%0A
     private 

add benchmarks