Created
July 8, 2013 17:45
-
-
Save nicoulaj/5950889 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class ArrayListAddBenchmark extends ListBenchmark { | |
@Override | |
protected List<Object> newInstance() { | |
return new ArrayList<Object>(); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class LinkedListBenchmark extends ListBenchmark { | |
@Override | |
protected List<Object> newInstance() { | |
return new LinkedList<Object>(); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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