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 lastFromRxJavaLibrary() {
        Observable.range(1, MANY).last().subscribe();
    }

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

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

    @Benchmark
    public void lastFromExtrasFew() {
        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;
        }
    };

}

@@ -323,36 +323,43 @@
     public void 
-last
+takeLastOne
 FromRxJavaLibrar
@@ -398,21 +398,26 @@
 , MANY).
-l
+takeL
 ast(
+1
 ).subscr
@@ -457,28 +457,35 @@
 public void 
-last
+takeLastOne
 FromRxJavaLi
@@ -534,13 +534,18 @@
 EW).
-l
+takeL
 ast(
+1
 ).su
@@ -585,36 +585,43 @@
     public void 
-last
+takeLastOne
 FromExtras() %7B%0A 
@@ -753,12 +753,19 @@
 oid 
-last
+takeLastOne
 From

rename benchmarks and adjust for takeLastOne