private static void checkSizeLimit(final int sizeLimit, final int datasize, final int modulus) { final LightWeightCacheTestCase test = new LightWeightCacheTestCase(sizeLimit, sizeLimit, 1L << 32, 1L << 32, datasize, modulus); // keep putting entries and check size limit print(" check size ................. "); for (int i = 0; i < test.data.size(); i++) { test.cache.put(test.data.get(i)); Assert.assertTrue(test.cache.size() <= sizeLimit); } println("DONE " + test.stat()); }
/** check the following operations (1) put (2) remove & put (3) remove (4) remove & put again */ private static void check(final LightWeightCacheTestCase test) { // check put print(" check put .................. "); for (int i = 0; i < test.data.size() / 2; i++) { test.put(test.data.get(i)); } for (int i = 0; i < test.data.size(); i++) { test.put(test.data.get(i)); } println("DONE " + test.stat()); // check remove and put print(" check remove & put ......... "); for (int j = 0; j < 10; j++) { for (int i = 0; i < test.data.size() / 2; i++) { final int r = ran.nextInt(test.data.size()); test.remove(test.data.get(r)); } for (int i = 0; i < test.data.size() / 2; i++) { final int r = ran.nextInt(test.data.size()); test.put(test.data.get(r)); } } println("DONE " + test.stat()); // check remove print(" check remove ............... "); for (int i = 0; i < test.data.size(); i++) { test.remove(test.data.get(i)); } Assert.assertEquals(0, test.cache.size()); println("DONE " + test.stat()); // check remove and put again print(" check remove & put again ... "); for (int j = 0; j < 10; j++) { for (int i = 0; i < test.data.size() / 2; i++) { final int r = ran.nextInt(test.data.size()); test.remove(test.data.get(r)); } for (int i = 0; i < test.data.size() / 2; i++) { final int r = ran.nextInt(test.data.size()); test.put(test.data.get(r)); } } println("DONE " + test.stat()); final long s = (Time.now() - starttime) / 1000L; println("total time elapsed=" + s + "s\n"); }