Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
 package benchmark;
 
 import org.mapdb.*;
 
 import java.io.File;
 import java.util.Map;

Test basic CRUD operations with single thread
public class Basic_SingleThread {
    static final int MAX = (int) 1e8;
    static final String path = "/home/plain/db"+System.currentTimeMillis();
    public static void main(String[] args) {
        DB db = DBMaker.newFileDB(new File())
                .writeAheadLogDisable()
                .make();
        Map m = db.createTreeMap("test",32,true,false..,null);
        long time = System.currentTimeMillis();
        //insert
        for(Integer i=0;i<;i++){
            m.put(i"aaadqw "+i);
        }
        long time2 = System.currentTimeMillis();
        ..println("INSERT: "+(time2 - time));
        time = time2;
        //RANDOM READS
        for(int i=0;i<;i++){
            m.get(..nextInt());
        }
        time2 = System.currentTimeMillis();
        ..println("READS: "+(time2 - time));
        time = time2;
        //RANDOM UPDATES
        for(int i=0;i<;i++){
            m.put(..nextInt(), "asdasdasdasd"+i);
        }
        time2 = System.currentTimeMillis();
        ..println("UPDATES: "+(time2 - time));
        time = time2;
        db.close();
    }
New to GrepCode? Check out our FAQ X