for (int i = 0; i < MAX_ITEMS; i++){
new String(""+i);
}
double ellapsedTime, totalTime;
JsCache cache = JsCache.create();
log("Testing cache : put "+MAX_ITEMS+" items in the cache :");
totalTime = ellapsedTime = Duration.currentTimeMillis();
for (int i = 0; i < MAX_ITEMS; i++){
cache.put(new String(""+i), new Object());
}
ellapsedTime = Duration.currentTimeMillis() - ellapsedTime;
log(" ellapsed Time : "+ellapsedTime);
log("Testing cache : get "+MAX_ITEMS+" from the cache :");
ellapsedTime = Duration.currentTimeMillis();
for (int i = 0 ; i < MAX_ITEMS; i++){
int random = Random.nextInt(MAX_ITEMS);
cache.get(new String(""+random));
}
ellapsedTime = Duration.currentTimeMillis() - ellapsedTime;
log(" ellapsed Time : "+ellapsedTime);
log("Testing cache : run "+MAX_ITEMS+" exist() in the cache :");
ellapsedTime = Duration.currentTimeMillis();
for (int i = 0 ; i < MAX_ITEMS; i++){
int random = Random.nextInt(MAX_ITEMS);
cache.exists(new String(""+random));
}
ellapsedTime = Duration.currentTimeMillis() - ellapsedTime;
log(" ellapsed Time : "+ellapsedTime);
log("Testing cache : visit all keys() :");
ellapsedTime = Duration.currentTimeMillis();
for (String s: cache.keys()) {
}
ellapsedTime = Duration.currentTimeMillis() - ellapsedTime;
log(" ellapsed Time : "+ellapsedTime);
log("Testing cache : visit all values() :");
ellapsedTime = Duration.currentTimeMillis();
for (Object o: cache.elements()) {
}
ellapsedTime = Duration.currentTimeMillis() - ellapsedTime;
log(" ellapsed Time : "+ellapsedTime);
totalTime = Duration.currentTimeMillis() - totalTime;