0

嗨,我正在尝试使用 2.0.8 使用 MapDB 堆外内存,我也尝试了 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

我错过了什么?

谢谢

4

0 回答 0