|Just another Perl shrine|
Fastest way of XML -> perl structureby sectokia (Acolyte)
|on Mar 19, 2017 at 22:16 UTC||Need Help??|
sectokia has asked for the
wisdom of the Perl Monks concerning the following question:
Hi wise monks,
What is the fastest way to go from XML to perl? I have 16MB+ XML files that are taking many seconds.
I have tried XML::Simple XML::Fast and XML::Bare, but all are surprisingly slow. Normalised its: Simple 1.0, fast 0.55, bare 0.4. But even then, that seems rediculously slow, with 3GHz machines still taking 10+ seconds.
In comparison, I wrote a dodgy C program that takes the XML and outputs a eval'able perl literal structure of nested array/hashes. Running the program and eval'ing the output is nearly 3x faster than xml::bare!
However I feel like I am re-inventing the wheel here (my dodgy program doesn't support attributes) and people must know a fast way to go from xml to perl already?
My other question is: Since eval is where most of the processing time is, is there some sort of 'direct' memory format for perl? For example: I would like my C program to output a 'memory blob' of nested arrays/hashes/scalers that would go straight into Perl, without having to 'parse'/'eval' anything.
The structures I want to put in are mostly like this: