private static void cacheTest(int RELEASE_RATE) //0..8
{
System.out.println("creating " + OBJCOUNT + " objects using ObjectCache, release() rate: " + ((RELEASE_RATE + 0.0) / 8) + "...");
gc();
int oc = (int) OBJCOUNT;
ObjectCache cache = ObjectCacheTest.cache;
long start = System.currentTimeMillis();
if (RELEASE_RATE == 8)
for (int i = 0; i < oc; ++i) {
cache.release(cache.get());
}
else if (RELEASE_RATE == 0)
for (int i = 0; i < oc; ++i) {
cache.get();
}
else
for (int i = 0; i < oc; ++i) {
Object o = cache.get();
if ((i & 7) <= RELEASE_RATE) cache.release(o);
}
long end = System.currentTimeMillis();
System.out.println("done. Time spent: " + (end - start) + " millis");
gc();
}