4 ms·
Warning! Highly unscientific, non realistic test ahead! Running on a baremetal, idle server.. python -m timeit -r 10 -n 100000 -s 'import json' 'j="""[{"t":
by buster 13y ago
Warning! Highly unscientific, non realistic test ahead!
Running on a baremetal, idle server..
python -m timeit -r 10 -n 100000 -s 'import json' 'j="""[{"t":"Hello"}]"""; json.loads(j)[0]["t"]'
100000 loops, best of 10: 9.07 usec per loop
python -m timeit -r 10 -n 100000 -s 'from xml.dom import minidom' 'xml = "<t>Hello</t>"; minidom.parseString(xml).getElementsByTagName("t")'
100000 loops, best of 10: 74.9 usec per loop
python -m timeit -r 10 -n 100000 -s 'from xml.dom import minidom' 'xml = "<t>Hello</t>"; minidom.parseString(xml).firstChild.firstChild.wholeText'
100000 loops, best of 10: 76.6 usec per loop
Given that the "study" comes from a "markup conference" that has XML all over its website and given the fact that XML documents (uncompressed, in memory) are much larger and that XML is a much much more complex standard, i seriously doubt the conclusion that XML and JSON are "almost the same" in terms of speed and memory usage.
Or simply put: How is it technically even feasible that an XML document that, by its nature, is much more complex (and thus i imagine a XML parser to be much more complex) can be parsed as fast as JSON with more or less the same memory footprint?
Wouldn't that only suggest that the JSON parser that is tested is just not as optimized as the XML parser?
I can imagine that a webbrowsers XML parser is much more optimized and mature then its JSON parser, given that it's a browser that mainly needs to parse HTML/XML?
Does it mean i should switch to using XML instead of JSON in commandline tools?
Or to put it another way:
The headline "XML Can Give the Same Performance as JSON" is probably true for browsers which have had years in improving the XML parser. But i don't think this can be a general conclusion.
- corresation 13y agoGiven that the "study" comes from a "markup conference" that has XML all over its website So? The overwhelming majority of JSON advocacy comes from developers who happen to know JavaScript, and thus JSON appeals to them. Virtually everyone speaks from the position of self-interest.
- jimfuller 13y agoyes, a bit of a cheap shot that ... and the guy works at a company that makes MarkLogic server which spits out XML ... but it also spits out JSON (all at very large scale I may add) so choose your poison. Until someone replies with the same experimental rigor to refute the findingsthen I think the observations this paper makes stands ... thats how peer reviewed journals work. The paper is not saying 'XML is better' or even 'XML is faster' ... its just addressing the perception that XML is slow in certain scenarios which has become a default myth. JSON has been accepted as a datatype in the Markup conferences of the world its great for data transfer, XML is a compromise on many different levels but tends to be good for mixed content and documents. I think we've all moved on.