@Setup(Level.Trial) publicvoidsetup(){ datasetA = new DataSet(size); datasetB = new DataSet(datasetA); }
@Benchmark publicintsumInt(){ int sum = 0; for (int index = 0; index < datasetA.intSize(); ++index) { sum += datasetA.intGet(index); } return sum; }
@Benchmark publicintsumLong(){ int sum = 0; for (long index = 0; index < datasetA.longSize(); ++index) { sum += datasetA.longGet(index); } return sum; }
@Benchmark publicbooleanequalsInt(){ for (int index = 0; index < datasetA.intSize(); ++index) { if(datasetA.intGet(index) != datasetB.intGet(index)) returnfalse; } returntrue; } @Benchmark publicbooleanequalsLong(){ for (long index = 0; index < datasetA.longSize(); ++index) { if(datasetA.longGet(index) != datasetB.longGet(index)) returnfalse; } returntrue; }
@Benchmark publicvoidfillInt(){ for (int index = 0; index < datasetA.intSize(); ++index) { datasetA.intSet(index, size); } }
@Benchmark publicvoidfillLong(){ for (long index = 0; index < datasetA.longSize(); ++index) { datasetA.longSet(index, size); } } @Benchmark publicvoidcopyInt(){ for (int index = 0; index < datasetA.intSize(); ++index) { datasetA.intSet(index, datasetB.intGet(index)); } }
@Benchmark publicvoidcopyLong(){ for (long index = 0; index < datasetA.longSize(); ++index) { datasetA.longSet(index, datasetB.longGet(index)); } } }