4 ms·
The 10x speed difference is impressive, but they do list some caveats in the benchmark: * AsmXml does not copy attributes and text unless necessary (when it in
by jasondavies 16y ago
The 10x speed difference is impressive, but they do list some caveats in the benchmark:
* AsmXml does not copy attributes and text unless necessary (when it includes entity or char references), so, if you need a zero terminated string, you must copy the value first.
* On the other hand, it does more work since it also decodes attributes (O(1) access time), saving a lot of time to the caller of the library.
I'd be interested to know whether it would still be that much faster than a C library that had the same tradeoffs e.g. no copying of attributes/text unless necessary.
I also wonder if it's worth it for existing C libraries to incorporate hand-optimised asm from this library (only when targeting x86 of course) if it provides much more benefit than the above tradeoffs.
- roel_v 16y ago"* On the other hand, it does more work since it also decodes attributes (O(1) access time), saving a lot of time to the caller of the library" This part I didn't understand. Does he mean transforming the document's encoding into the platform's native encoding? How can the access time of a list of attributes be in constant time? I mean, there needs to be some form of lookup from the name of the attribute to its value. And how do the two relate to each other?
- Nitramp 16y agoThe trick is that through their mapping, they have an array of "attributes" for every element, with a specific offset for each attribute with a certain name. During construction, they build that array according to the names, so they do the lookup once during construction.
- roel_v 16y agoBut then how do you reference the attributes? I get the code to parse my xml document, then afterward I want to access a certain attribute (by name). The library would still need to look up the index of that attribute, at O(n) complexity, right?
- lincolnq 16y agono, quoting from grandparent: "a specific offset for each attribute with a certain name" -- e.g., for all <image> element, 'width' is always at attributes[0] and 'height' is at attributes[1], presumably regardless of whether that particular image has a width and height attribute.
- roel_v 16y agoOh I see, thanks.
- humbledrone 16y agoThe RapidXml library is pretty similar to AsmXml, except that it's written in C++. Browsing around the "Links" section on the AsmXml website, I came across a site that performs speed comparisons between the various parsers out there. RapidXml does appear to come pretty close to AsmXml in terms of speed. Source: http://xmlbench.sourceforge.net/results/benchmark200910/index.html http://xmlbench.sourceforge.net/results/benchmark200910/inde...
- yatsyk 16y agoThank you for RapidXml information. From RepidXml site: It is an in-situ parser written in modern C++, with parsing speed approaching that of strlen function executed on the same data. bold statement :)
- boris 16y agoExcept that RapidXml is not a real XML parser. It is a parser that can only handle a subset of XML 1.0 language. See: http://www.codesynthesis.com/~boris/blog/2008/05/19/real-xml-parser/ http://www.codesynthesis.com/~boris/blog/2008/05/19/real-xml...