package com.github.davidmoten.rx;

import org.openjdk.jmh.annotations.Benchmark;

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

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

public class Benchmarks {

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

    @Benchmark
    public void scanFromRxJavaLibrary() {
        Observable.range(1, MANY).scan(0, COUNT).last().subscribe();
    }

    @Benchmark
    public void scanFromExtras() {
        Observable.range(1, MANY).scan(0, COUNT).lift(OperatorLast.<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;
        }
    };

}

@@ -320,28 +320,28 @@
 public void 
-scan
+last
 FromRxJavaLi
@@ -384,29 +384,134 @@
 , MANY).
-scan(0, COUNT
+last().subscribe();%0A    %7D%0A%0A    @Benchmark%0A    public void lastFromRxJavaLibraryFew() %7B%0A        Observable.range(1, FEW
 ).last()
@@ -562,20 +562,20 @@
 ic void 
-scan
+last
 FromExtr
@@ -619,21 +619,150 @@
 NY).
-scan(0, COUNT
+lift(OperatorLast.%3CInteger%3E create()).subscribe();%0A    %7D%0A%0A    @Benchmark%0A    public void lastFromExtrasFew() %7B%0A        Observable.range(1, FEW
 ).li

update benchmarks