use of com.github.drinkjava2.jdbpro.handler.SimpleCacheHandler in project jSqlBox by drinkjava2.
the class HandlersTest method testSimpleCacheHandler.
@Test
public void testSimpleCacheHandler() {
for (int i = 0; i < 10; i++) {
// warm up
ctx.nQuery(new Wrap(new EntityListHandler(DemoUser.class), new SimpleCacheHandler()), "select u.** from DemoUser u where u.age>?", 0);
ctx.nQuery(new Wrap(new EntityListHandler(DemoUser.class)), "select u.** from DemoUser u where u.age>?", 0);
}
long start = System.currentTimeMillis();
for (int i = 0; i < 1000; i++) {
List<DemoUser> result = ctx.nQuery(new Wrap(new EntityListHandler(DemoUser.class), new SimpleCacheHandler()), "select u.** from DemoUser u where u.age>?", 0);
Assert.assertTrue(result.size() == 99);
}
long end = System.currentTimeMillis();
String timeused = "" + (end - start) / 1000 + "." + (end - start) % 1000;
System.out.println(String.format("%28s: %6s s", "With Cache", timeused));
start = System.currentTimeMillis();
for (int i = 0; i < 1000; i++) {
List<DemoUser> result = ctx.nQuery(new Wrap(new EntityListHandler(DemoUser.class)), "select u.** from DemoUser u where u.age>?", 0);
Assert.assertTrue(result.size() == 99);
}
end = System.currentTimeMillis();
timeused = "" + (end - start) / 1000 + "." + (end - start) % 1000;
System.out.println(String.format("%28s: %6s s", "No Cache", timeused));
}
Aggregations