-
-
Notifications
You must be signed in to change notification settings - Fork 309
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Detail on Array mode #43
Comments
My PR was for attrNodeName, and mean that all attributes present as child object with this name using it original names (or prefixed if it specified).
Mean that single tag value should be wrapped as array of object, instead of single object |
Thanks for your quick response. As you initially mentioned Thanks |
@amitguptagwl https://github.com/Leonidas-from-XIV/node-xml2js#options |
There was an option It's fine if something is not implemented, my main concern is if something is half implemented. Thanks a lot for your active discussion and contribution. |
That was my first PR to this project )) |
Thanks @Delagen . I have just compared the performance of xml2js(0.4.19) with both version V2, V3 and I feel |
Strange... at about 20M |
where did you get this figure from? May be I'm testing in the wrong way. |
I'l take sample XML SOAP:response with ~80К CDATA base64 response
And parse it 100 times. On 500 with 1000 elements (~80-90MB) |
I'm reading 13m XML file in a string and using benchmark js to test suite.add('xml2js', {
'defer': true,
'fn' : function(deferred) {
xml2js.parseString(largeXmlData,function(err,result){
if (err) throw err;
deferred.resolve();
});
}
})
.on('complete', function() {
console.log(this.name + ":" + this.hz + " requests/second");
})
.run({ 'async': true }); |
You're making me to push my changes.... Can you plz share the gist ? I'm definitely doing something wrong. Because for me xml2js always takes 3s for both small (1.5kb) and big (98mb) files. |
@amitguptagwl Can you share benchmark project? I am using mocha with simple loop
Try to remove async & defer, because callback is syncronous |
It is just a file in benchmark folder. Let me share the code;
|
@amitguptagwl xml2js speed vary on data. For example: modified 3 lines
where test.xml something like
And result even with validation (which unneeded if user trust source) xml2js does not have on 10000 repeat That old error on SAX parser. |
Agree, with the XML having CDATA benchmarks are as follows; xml to json V1: 36.2170364893656 requests/second for small file xml to json V1: 44887.09328602369 requests/second for small file without CDATA xml to json V1:22418.135460499547 requests/second But for big file without CDATA For data you shared (When I remove CADATA part) File I made (13m) xml to json V1:1.0754129079969013 requests/second I can work more to speed it up as it gives better performance at least in case of CDATA or when file size is less than 3-4 mb. |
There is some more interesting result. I have created parser V3 which is not doing validation and I've done some more changes. Now when I tested against 98m file V1: error out due to RE But when I read the output of xml2js, it just read 2 starting tags and skipped rest of the XML. Hence it was fast. Moreover, I modified your example and added XML prolog and DOCTYPE. In this case xml2js error out. Now the only problem is parser V1 is up to 4 times faster than V2 or V3 but it works only for small file up to 15mb then it errors out. I could have rewritten the JS RE engine if I get the time to complete my other project grapes. |
4 times not too big degradation for support of large files, I think it still faster than xml2js.
Can you share your example XML? |
please check 'spec/assets/" folder. I'm using sample.xml, ptest.xml, and midsize.xml |
Performance (should have been discussed in separate thread) is degraded to handle some cases of XML but no impact due to large files now. I have removed |
@Delagen , I'm rewriting the XML parser to handle large files and for other useful features. Hence I was revisiting the test cases. As you did the changes to parse attributes as array in #23 , I have a query to clear the expectations;
In the test "should parse nodes as arrays" in file
xmlParser_spec.js
, somewhere attribute is parsed as object and somewhere as array.Can you please clear me the expectation so I'll implement the same in new code?
In my understanding / expectations
The text was updated successfully, but these errors were encountered: