Topic: [简单测评]jdom beta9解析xml大文件

  Print this page

1.[简单测评]jdom beta9解析xml大文件 Copy to clipboard
Posted by: Jove
Posted on: 2003-05-07 10:32

发信人: Jove (死生契阔,与子相悦,执子之手,与子偕老), 信区: XML
标 题: Re: 哪里有较大的XML文档?
发信站: 日月光华 (2003年05月03日20:14:28 星期六), 站内信件

今天无聊一把,试着用jdom beta9解析xml大文件
找到那个match.xml,解压后500M,试图用saxbuilder解析,内存停在700M就不动了,放弃
同一个ftp,down了个interpro.xml.gz interpro.dtd.Z 分别用winrar和gunzip解压
这是个20M左右的数据文件

测试代码如下
import org.jdom.Document;
import org.jdom.input.SAXBuilder;

public class Demo{
public static void main(String[] args){
System.out.println("start parsing");
SAXBuilder builder=new SAXBuilder();
try{
Document doc = builder.build("interpro.dtd.xml");
}catch(Exception e){
e.printStackTrace();
}
System.out.println("end.");
System.out.println(Runtime.getRuntime().totalMemory()/1024/1024+"M")
System.exit(0);
}
}

运行结果
G:\待刻盘>java -Xmx500m -cp jdom.jar;. Demo
start parsing
end.
142M

然后,用editplus修改xml,去掉dtd头
(一开始用editplus,xmlspy,wordpad修改都接近死机状态,最后把editplus的xml语法高
亮设置去掉才可以顺利)

结果,内存占用128M

====
用DOMBuilder解析,代码类似
DOMBuilder builder=new DOMBuilder();
try{
Document doc = builder.build(new
java.io.File("interpro-no.dtd.xml"));
}catch(Exception e){
e.printStackTrace();
}

结果是内存占用215M

====
结论:
jdom的SAXBuilder没有想象的神奇, 不过结果还算可以接受

以上就是今天的无聊之举. 报告完毕

2.Re:[简单测评]jdom beta9解析xml大文件 [Re: Jove] Copy to clipboard
Posted by: floater
Posted on: 2003-05-07 11:46

Could you please print out the time stamps so we could figure out how long it takes?

3.Re:[简单测评]jdom beta9解析xml大文件 [Re: floater] Copy to clipboard
Posted by: Jove
Posted on: 2003-05-07 17:02

floater wrote:
Could you please print out the time stamps so we could figure out how long it takes?

我的配置: 赛扬II 800, 392M RAM
java -Xmx400m -cp .;jdom.jar Demo sax
Start..
Total time: 23224ms
128M

java -Xmx400m -cp .;jdom.jar Demo dom
Start..
Total time: 41039ms
356M

从JDOM beta7开始DOMBuilder.build(File)已经不推荐使用了. 所以这个比较意义不大
或许有人已经做过jaxp,xerces的benchmark

Demo.java (1.1k)

4.Re:[简单测评]jdom beta9解析xml大文件 [Re: Jove] Copy to clipboard
Posted by: floater
Posted on: 2003-05-07 21:47

Thanks for the info, enough for me.

5.Re:[简单测评]jdom beta9解析xml大文件 [Re: Jove] Copy to clipboard
Posted by: bawanglongqiqi
Posted on: 2003-05-20 14:28

thanks,有收获!


   Powered by Jute Powerful Forum® Version Jute 1.5.6 Ent
Copyright © 2002-2021 Cjsdn Team. All Righits Reserved. 闽ICP备05005120号-1
客服电话 18559299278    客服信箱 714923@qq.com    客服QQ 714923