package com.github.davidmoten.rx;

import java.util.ArrayList;
import java.util.LinkedList;
import java.util.List;

import org.openjdk.jmh.annotations.Benchmark;

import rx.Observable;

public class Benchmarks {

    private static final int MANY = 1000000;

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

    @Benchmark
    public void addAndIterateArrayList() {
        addAndIterateList(new ArrayList<Integer>());
    }

    @Benchmark
    public void addAndIterateLinkedList() {
        addAndIterateList(new LinkedList<Integer>());
    }

    private void addAndIterateList(List<Integer> list) {
        list.add(1);
        list.add(2);
        list.add(3);
        list.add(4);
        list.add(5);
        for (Integer element : list) {
        }
        list.size();
    }

}

@@ -32,841 +32,33 @@
 x;%0A%0A
-import java.util.ArrayList;%0Aimport java.util.LinkedList;%0Aimport java.util.List;%0A%0Aimport org.openjdk.jmh.annotations.Benchmark;%0A%0Aimport rx.Observable;%0A%0Apublic class Benchmarks %7B%0A%0A    private static final int MANY = 1000000;%0A%0A    @Benchmark%0A    public void takeLastOneFromRxJavaLibraryMany() %7B%0A        Observable.range(1, MANY).takeLast(1).subscribe();%0A    %7D%0A%0A    @Benchmark%0A    public void addAndIterateArrayList() %7B%0A        addAndIterateList(new ArrayList%3CInteger%3E());%0A    %7D%0A%0A    @Benchmark%0A    public void addAndIterateLinkedList() %7B%0A        addAndIterateList(new LinkedList%3CInteger%3E());%0A    %7D%0A%0A    private void addAndIterateList(List%3CInteger%3E list) %7B%0A        list.add(1);%0A        list.add(2);%0A        list.add(3);%0A        list.add(4);%0A        list.add(5);%0A        for (Integer element : list) %7B%0A        %7D%0A        list.size();%0A    %7D
+public class Benchmarks %7B
 %0A%0A%7D%0A

trim benchmarks