Skip to content

Instantly share code, notes, and snippets.

@nicoulaj
Created July 8, 2013 17:45
Show Gist options
  • Save nicoulaj/5950889 to your computer and use it in GitHub Desktop.
Save nicoulaj/5950889 to your computer and use it in GitHub Desktop.
public class ArrayListAddBenchmark extends ListBenchmark {
@Override
protected List<Object> newInstance() {
return new ArrayList<Object>();
}
}
public class LinkedListBenchmark extends ListBenchmark {
@Override
protected List<Object> newInstance() {
return new LinkedList<Object>();
}
}
abstract class ListBenchmark {
List<Object> list;
@Setup(Iteration)
public void setupIteration() {
list = newInstance();
}
abstract protected List<Object> newInstance();
@GenerateMicroBenchmark
public boolean add() {
return list.add(new Object());
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment