Java 如何改进GWT XML解析?
如何改进GWT中的xml解析 我的xml如下,有1条记录 解析100条记录GWT需要8秒 有没有办法提高绩效?请看我的gwt代码来解析xmlJava 如何改进GWT XML解析?,java,xml,gwt,xml-parsing,Java,Xml,Gwt,Xml Parsing,如何改进GWT中的xml解析 我的xml如下,有1条记录 解析100条记录GWT需要8秒 有没有办法提高绩效?请看我的gwt代码来解析xml 12345678 12345678 我的GWT解析代码如下: 私有静态列表解析记录(文档维护、, 列出记录){ NodeList recordNodeList=mainDOM.getElementsByTagName(“记录”);//记录节点 RecordInfo RecordInfo=null 似乎不太可能用8秒的时间来解析—我猜这是花在试图在网
似乎不太可能用8秒的时间来解析—我猜这是花在试图在网络上查找资源(如DTD访问)上的时间。您是在开发模式下运行还是编译它以实现JavaScript代码。根据我的经验,开发模式的运行速度比交叉编译为JavaSc时慢10倍script.Still 8s是很多!你曾经看到过大部分时间都浪费在哪里吗?是的,我在开发模式下解析xml。在生产模式下只需要较少的时间,即377毫秒:)。为什么开发需要太多时间?开发人员需要在开发模式下测试数据。开发模式用插件解释代码。你可以发送你的GWT插件的代码,该插件查看它是什么命令并在浏览器中执行。通过这种方式,它可以触发断点,获取变量的当前值等。因此,您可以从调试器中获得所需的一切。您甚至可以更改代码,只需刷新浏览器即可获得更新:)。如果您将其编译为JavaScript GWT,则这需要很多时间,但运行速度很快(8s,而377ms^^^^),但编译需要>20秒,因此您不想将其用于开发^^
for(int i=0;i<recordNodeList.getLength();i++){ //iteration over record node
recordInfo = new RecordInfo();
recordInfo.setColumnCount(columnInfoList.size());
recordInfo.setColumnInfoList(columnInfoList);
HashMap<String, String> recordsColumnValueHashMap = new HashMap<String, String>();
Element element = ((Element)recordNodeList.item(i)); //Record node
NamedNodeMap recNodeMap = recordNodeList.item(i).getAttributes();
if(i==0){
}else{
recordInfo.setProductid(recNodeMap.getNamedItem("productid").getNodeValue());
recordInfo.setProductidext(recNodeMap.getNamedItem("productidext").getNodeValue());
recordInfo.setProductkeyid(recNodeMap.getNamedItem("productkeyid").getNodeValue());
recordInfo.setProductversion(Integer.parseInt(recNodeMap.getNamedItem("productversion").getNodeValue()));
recordInfo.setFEDRecord(Boolean.parseBoolean(recNodeMap.getNamedItem("isFEDRecord").getNodeValue()));
recordInfo.setValidationstatus(recNodeMap.getNamedItem("validationstatus").getNodeValue());
recordInfo.setSelected(Boolean.parseBoolean(recNodeMap.getNamedItem("selected").getNodeValue()));
recordInfo.setAccessmode(recNodeMap.getNamedItem("accessmode").getNodeValue());
recordInfo.setIsedited(recNodeMap.getNamedItem("isedited").getNodeValue());
NodeList recList = element.getElementsByTagName("RecordAttribute");
for(int j=0;j<recList.getLength();j++){ //iterating all record attributes
NodeList child = recList.item(j).getChildNodes();
if("Value".equalsIgnoreCase(child.item(k).getNodeName())){
if(child.item(k).getFirstChild()!=null){
String value = child.item(k).getFirstChild().getNodeValue();
//System.out.println("Value = "+child.item(k).getFirstChild().getNodeValue());
recordInfo.setValue(value);
String columnName = recList.item(j).getAttributes().getNamedItem("name").getNodeValue();
recordsColumnValueHashMap.put(columnName, value);
}
}
if("OldValue".equalsIgnoreCase(child.item(k).getNodeName())){
if(child.item(k).getFirstChild()!=null){
String oldValue = child.item(k).getFirstChild().getNodeValue();
//System.out.println("oldValue ="+child.item(k).getFirstChild().getNodeValue());
recordInfo.setOldValue(oldValue);
}
}
}
}
recordInfo.setRecordHashMap(recordsColumnValueHashMap);
}
records.add(recordInfo);
}
return records;
}