Beefy Boxes and Bandwidth Generously Provided by pair Networks
Welcome to the Monastery
 
PerlMonks  

Re: enabling XML::Rabbit serialization

by Jenda (Abbot)
on Dec 19, 2012 at 19:02 UTC ( #1009602=note: print w/ replies, xml ) Need Help??


in reply to enabling XML::Rabbit serialization

I don't think I understand. The XML is a serialization of the data already, why do you want to have another? If you are parsing the same XML several times during one run time of the script, then just keep it in memory. If it's a config, it's unlikely it's gonna be prohibitively big.

If you parse the XML just one each time you run the script, then unless the script is a very tiny thing, the time spent parsing the XML will be irrelevant. Besides you'd have to parse the other serialization as well!

If the working with the XML::Rabbit created objects is slow, you'll have to use something else. In either case, FIRST PROFILE the script to find out where the problem is and THEN OPTIMIZE the problematic part.

Jenda
Enoch was right!
Enjoy the last years of Rome.


Comment on Re: enabling XML::Rabbit serialization
Re^2: enabling XML::Rabbit serialization
by glasswalk3r (Pilgrim) on Dec 28, 2012 at 11:37 UTC

    Your observation is right Jenda, but I would like to give a try to Sereal since it seems to be faster and use less memory.

    And yes, the script executes very quickly since it will be a Nagios plugin. Parsing the XML once is useful because somebody must configure de plugin, but for later executions, recovering the data from the XML as plain Moose objects would be faster and use less memory. After parsing the XML, it is just a matter to save the new objects in the file system and recovering them latter. Since of it like a cache.

    Looks like I will need to clone the XML::Rabbit objects by copying their "attributes" to plain Moose objects.

    Alceu Rodrigues de Freitas Junior
    ---------------------------------
    "You have enemies? Good. That means you've stood up for something, sometime in your life." - Sir Winston Churchill

      Do they have to be Moose objects? And does it have to be XML::Rabbit? You can just as easily set up XML::Rules to build a data structure (either plain or blessed as plain old Perl objects) and thus have something easily serializable.

      Jenda
      Enoch was right!
      Enjoy the last years of Rome.

        My project already uses Moose extensively. Besides, XML::Rabbit really does what I expected despite this tiny detail :-)

        Alceu Rodrigues de Freitas Junior
        ---------------------------------
        "You have enemies? Good. That means you've stood up for something, sometime in your life." - Sir Winston Churchill

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1009602]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others imbibing at the Monastery: (18)
As of 2014-07-10 15:01 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    When choosing user names for websites, I prefer to use:








    Results (212 votes), past polls