db4o java,db4o Java版性能测试评估

db4o java,db4o Java版性能测试评估publicclassTestdb4oIndex{publicstaticclassRecord{StringstrKey;longintKey;};publicstaticclassAssert{publicstaticvoidthat(booleancondition){if(!condition){thrownewError(“Assertio…

大家好,又见面了,我是你们的朋友全栈君。

public class Testdb4oIndex {

public static class Record {

String strKey;

long   intKey;

};

public static class Assert {

public static void that(boolean condition) {

if (!condition) {

throw new Error(“Assertion failed”);

}

}

}

static final String FILE = “testindex.yap”;

final static int nRecords = 100000;

static public void main(String[] args) {

new File(FILE).delete();

Configuration conf = Db4o.configure();

conf.objectClass(Record.class).objectField(“strKey”).indexed(true);

conf.objectClass(Record.class).objectField(“intKey”).indexed(true);

conf.weakReferences(false);

conf.discardFreeSpace(Integer.MAX_VALUE);

conf.automaticShutDown(false);

conf.lockDatabaseFile(false);

ObjectContainer db = Db4o.openFile(FILE);

long start = System.currentTimeMillis();

long key = 1999;

int i;

for (i = 0; i < nRecords; i++) {

Record rec = new Record();

key = (3141592621L*key + 2718281829L) % 1000000007L;

rec.intKey = key;

rec.strKey = Long.toString(key);

db.set(rec);

}

db.commit();

System.out.println(“Elapsed time for inserting ” + nRecords + ” records: “

+ (System.currentTimeMillis() – start) + ” milliseconds”);

start = System.currentTimeMillis();

key = 1999;

for (i = 0; i < nRecords; i++) {

key = (3141592621L*key + 2718281829L) % 1000000007L;

Query q = db.query();

q.constrain(Record.class);

q.descend(“intKey”).constrain(new Long(key));

Record rec1 = (Record)q.execute().next();

q = db.query();

q.constrain(Record.class);

q.descend(“strKey”).constrain(Long.toString(key));

Record rec2 = (Record)q.execute().next();

Assert.that(rec1 != null && rec1 == rec2);

}

System.out.println(“Elapsed time for performing ” + nRecords*2 + ” index searches: “

+ (System.currentTimeMillis() – start) + ” milliseconds”);

start = System.currentTimeMillis();

Query q = db.query();

q.constrain(Record.class);

ObjectSet objectSet = q.execute();

while(objectSet.hasNext()){

db.delete(objectSet.next());

}

db.commit();

System.out.println(“Elapsed time for deleting ” + nRecords + ” records: “

+ (System.currentTimeMillis() – start) + ” milliseconds”);

db.close();

}

}

版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 举报,一经查实,本站将立刻删除。

发布者:全栈程序员-站长,转载请注明出处:https://javaforall.net/162596.html原文链接:https://javaforall.net

赞 (0)
全栈程序员-站长的头像全栈程序员-站长


相关推荐

  • JCF_jcf应用培训

    JCF_jcf应用培训JCF容器框架:对外接口:容器中所能存放的抽象的数据类型;接口实现:可复用的数据结构;算法:对数据的查找和排序;容器的框架优点:提高存储效率;避免程序员重复查找;JCF主要数据结构:列表、集合、映射。List:列表有序的Collection允许重复允虚嵌套List三大类:ArrayList:(不支持同步)利用索引快速定位。不适合指定位置的插入、删除操作。适合变动不大,主要用于查询的数据。容量可以动态调整容量填满时自动扩充容量的50%。Linke

    2022年10月22日
  • 仿百度首页选项卡切换效果

    效果:http://hovertree.com/texiao/jquery/71/代码如下:转自:http://hovertree.com/h/bjaf/n781jmfy.htm特效汇总:http

    2021年12月24日
  • bit rate / frame rate /sample rate等等

    bit rate / frame rate /sample rate等等原文地址码率:Bit Rate,指视频或音频文件在单位时间内使用的数据流量,该参数的单位通常是Kbps,也就是千比特每秒。通常2000kbps~3000kbps就已经足以将画质效果表现到极致了。码率参数与视频文件最终体积大小有直接性的关系。 (编码码率—软件)  混合码率:Overall Bit Rate,指视频文件中视频和音频混合后的整体平均码率。一般描述一个视频文件的码率都是指

    2022年10月17日
  • struts的内置_struts自定义拦截器

    struts的内置_struts自定义拦截器一般我们的web应用都是只有在永固

    2022年9月25日
  • UpdatePanel嵌套

    UpdatePanel嵌套UpdatePanel主要是防止页面的刷新,但是项目中有时候可能要根据不同的事件更新不同的地方。 这时候UpdatePanel嵌套可以很好的解决这个问题。 在事例中主要是用时间来记录每个UpdatePanel的刷新。 前台代码: UpdatePanel嵌套

关注全栈程序员社区公众号