final long[] lives = { 5000, 4000, 3000, 2000, 1000 };
// Create objects
for (int i = 0; i < OBJECTS_ALLOCATED; i++) {
GameEvent event = values.get(i);
event.setId(i);
event.setStrength(i % 50);
event.setTarget(i % 5);
}
final long middle = System.nanoTime();
// Use objects
for (int i = 0; i < OBJECTS_ALLOCATED; i++) {
GameEvent event = values.get(i);
int target = event.getTarget();
long lifeRemaining = lives[target];
if (lifeRemaining > 0) {
lives[target] = lifeRemaining - event.getStrength();
}
}
final long reads = System.nanoTime() - middle;
final long writes = middle - start;