Friday, May 18, 2012
Performance test of find cell
public void testFindCell_ICell() throws OutOfBoundsException {
System.out.println("findCell");
int testSize = 1000000;
UniqueRandomNumber urn = new UniqueRandomNumber(testSize);
ArrayListCellColl instance = new ArrayListCellColl();
AliveCell ac;
while (urn.hasNext()){
ac = new AliveCell();
int x = urn.getNext();
ac.setX(x);
ac.setY(x);
instance.addCell(ac);
}
TimerClass timer = new TimerClass();
timer.startTimer();
int counter = 0;
for (int i = 0; i<testSize;i++){
Random gen = new Random();
int z = gen.nextInt(testSize*2);
ac = new AliveCell();
ac.setX(z);
ac.setY(z);
if (instance.findCell(ac))counter++;
}
System.out.println("number found = " + counter);
timer.stopTimer();
System.out.println(timer.duration());
}
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment