jdom 性能 [英] jdom performance

查看:57
本文介绍了jdom 性能的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我目前正在使用本机 Java XML 处理库 (Xerces).我不能使用任何 sax 解析器,因为我需要随机访问 xml 节点.我发现解析 XML 文件时 CPU 使用率达到 100%.我正在处理大量小尺寸(1-10kb)-

I am currently using native Java XML processing library (Xerces). I can't use any sax parser because I need random access to xml nodes. I am finding that CPU usage goes 100% when I am parsing XML files. There are large number of small size (1-10kb) that I am processing like this-

while(hasFile){
processXMlfile(hasFile.next);
}

在 processXMlfile() 中,我正在构建解析和处理文件.

In processXMlfile() I am building parsing and processing file.

如果我转向 JDOM 库,我会获得任何性能优势吗?

If I move to JDOM library, will I gain any performance benefit?

推荐答案

瓶颈可能是 XML 解析,而 JDOM 可能会在幕后使用相同的 XML 解析器,因此不会有任何区别.

The bottleneck is probably XML parsing, and JDOM will likely use the same XML parser under the covers, so it won't make any difference.

解析大量小文件时的一个关键因素是避免解析器初始化成本.对所有文件重复使用相同的 XML 解析器实例.

A key factor when you are parsing lots of small files is to avoid the parser initialization costs. Reuse the same XML parser instance for all the files.

这篇关于jdom 性能的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆