Last active
August 29, 2015 14:11
-
-
Save raphw/bb23378a8f639a0a99d0 to your computer and use it in GitHub Desktop.
Benchmark of FastList
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
@State(Scope.Thread) | |
@BenchmarkMode(Mode.AverageTime) | |
@OutputTimeUnit(TimeUnit.MICROSECONDS) | |
public class FastListBenchmark { | |
private static final int LOAD = 10; | |
private ArrayList<Object> arrayList; | |
private FastList<Object> fastList; | |
private Random random; | |
@Setup | |
public void setUp() { | |
random = new Random(); | |
arrayList = new ArrayList<Object>(LOAD); | |
fastList = new FastList<Object>(Object.class, LOAD); | |
for (int i = 0; i < LOAD; i++) { | |
arrayList.add(new Object()); | |
fastList.add(new Object()); | |
} | |
} | |
@Benchmark | |
public Object testArrayList() { | |
return arrayList.get(random.nextInt(LOAD)); | |
} | |
@Benchmark | |
public Object testFastList() { | |
return fastList.get(random.nextInt(LOAD)); | |
} | |
public static void main(String[] args) throws RunnerException { | |
new Runner(new OptionsBuilder() | |
.include(FastListBenchmark.class.getSimpleName()) | |
.forks(1) | |
.build()).run(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment