Commit 08f8488b authored by Moritz Weichert's avatar Moritz Weichert
Browse files

Updates final benchmark

parent 0120b22b
......@@ -9,23 +9,27 @@ import java.util.concurrent.TimeUnit;
@State(Scope.Benchmark)
@BenchmarkMode(Mode.AverageTime)
@Warmup(iterations = 1)
@Measurement(iterations = 3)
@Warmup(iterations = 5, time = 1, timeUnit = TimeUnit.SECONDS)
@Measurement(iterations = 5, time = 1, timeUnit = TimeUnit.SECONDS)
@OutputTimeUnit(TimeUnit.MILLISECONDS)
@Fork(1)
public class MyBenchmark {
public static final int N = 1000;
@Param({"10","50","100","500","1000","5000","10000"})
public static int N;
@State(Scope.Thread)
public static class MyState {
BinarySearchTree mUnbalancedTree = null;
TreeSet<Integer> mTree = null;
LinkedList<Integer> mList = null;
@Setup(Level.Invocation)
public void doSetup() {
mUnbalancedTree = new BinarySearchTree();
mTree = new TreeSet<Integer>();
mList = new LinkedList<Integer>();
}
@TearDown(Level.Trial)
......@@ -39,11 +43,13 @@ public class MyBenchmark {
BinarySearchTree mUnbalancedTree = null;
TreeSet<Integer> mTree = null;
LinkedList<Integer> mList = null;
@Setup(Level.Invocation)
public void doSetup() {
mUnbalancedTree = new BinarySearchTree();
mTree = new TreeSet<Integer>();
mList = new LinkedList<Integer>();
for(int i = 0; i < N; i++) {
mUnbalancedTree.insert(i);
......@@ -52,6 +58,10 @@ public class MyBenchmark {
for(int i = 0; i < N; i++) {
mTree.add(i);
}
for(int i = 0; i < N; i++) {
mList.add(i);
}
//System.out.println("Do setup");
}
......@@ -81,6 +91,13 @@ public class MyBenchmark {
}
@Benchmark
public void list_create(MyState state) {
for(int i = 0; i < N; i++) {
state.mList.add(i);
}
}
/*
FIND
*/
......@@ -95,6 +112,11 @@ public class MyBenchmark {
state.mTree.contains(N-1);
}
@Benchmark
public void list_findLast(DefaultState state) {
state.mList.contains(N-1);
}
/*
DELETE
*/
......@@ -109,4 +131,28 @@ public class MyBenchmark {
state.mTree.remove(N-1);
}
@Benchmark
public void list_deleteLast(DefaultState state) {
state.mList.remove(N-1);
}
/*
INSERT
*/
@Benchmark
public void unbalanced_insertLast(DefaultState state) {
state.mUnbalancedTree.insert(N);
}
@Benchmark
public void balanced_insertLast(DefaultState state) {
state.mTree.add(N);
}
@Benchmark
public void list_insertLast(DefaultState state) {
state.mList.add(N);
}
}
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment