您好我正在尝试使用2.0.8使用MapDB offheap内存,我也试过1.0.8
db = DBMaker.newMemoryDirectDB().transactionDisable().asyncWriteFlushDelay(100).make();
我的测试:
@Test
public void testMapDBInsertionHash() {
@SuppressWarnings("rawtypes")
Map glimpses = db.hashMap("hashGlimpse") ;
long start = System.currentTimeMillis();
for (int i = 0; i < ITEMS; i++) {
if (i == 1000) {
glimpses.put(i, FIXED_STRING);
continue;
}
glimpses.put(i, RandomStringUtils.randomAlphabetic(10));
}
System.out.println(
"HashMap: Entries in map:" + glimpses.size() + " in: " + (System.currentTimeMillis() - start) + " ms.");
System.out.println("1000th entry:" + glimpses.get(1000));
}
- 原生:
@Test
public void testJavaInsertionHash() {
Map<Integer, String> glimpses = new HashMap<>();
long start = System.currentTimeMillis();
for (int i = 0; i < ITEMS; i++) {
if (i == 1000) {
glimpses.put(i, FIXED_STRING);
continue;
}
glimpses.put(i, RandomStringUtils.randomAlphabetic(10));
}
System.out.println(
"HashMap: Entries in map:" + glimpses.size() + " in: " + (System.currentTimeMillis() - start) + " ms.");
System.out.println("1000th entry:" + glimpses.get(1000));
}
MapDB比原生java hashMap慢10倍
我正在使用-XX:MaxDirectMemorySize=64M
我错过了什么?
感谢