Beefy Boxes and Bandwidth Generously Provided by pair Networks
The stupid question is the question not asked
 
PerlMonks  

Comment on

( #3333=superdoc: print w/ replies, xml ) Need Help??

Yep, in my benchmark JSON::XS was faster than Storable too. Fun, I saw this module before several times, but always stopped reading doc just after "JavaScript" words thinking that this is something useless for me.

Update: In case somebody interested, here's the results of testing for some serializing engines. I've just got simple XML example from wikipedia, encoded it using different methods and benchmarked the parsers.

Here's the code:

#!/usr/bin/perl use strict; use warnings; use XML::Twig; use XML::Simple; use JSON::XS; use YAML::Syck; use Data::Dumper; use Storable; use Fatal qw(open read close); my $xml; while(<DATA>){ $xml .= $_; } my $twig = XML::Twig->new(); my $href = XMLin($xml); my $dumper = Dumper($href); my $storable = Storable::freeze($href); my $json = encode_json($href); my $yaml = Dump($href); use Benchmark qw( cmpthese ); cmpthese -5, { 'XML::Simple' => sub { XMLin($xml) }, 'XML::Twig' => sub { $twig->parse($xml) }, 'JSON::XS' => sub { decode_json($json) }, 'YAML::Syck' => sub { Load($yaml) }, 'Storable' => sub { Storable::thaw($storable) }, 'Data::Dumper' => sub { eval($dumper) }, }; __DATA__ <recipe name="bread" prep_time="5 mins" cook_time="3 hours"> <title>Basic bread</title> <ingredient amount="8" unit="dL">Flour</ingredient> <ingredient amount="10" unit="grams">Yeast</ingredient> <ingredient amount="4" unit="dL" state="warm">Water</ingredient> <ingredient amount="1" unit="teaspoon">Salt</ingredient> <instructions> <step>Mix all ingredients together.</step> <step>Knead thoroughly.</step> <step>Cover with a cloth, and leave for one hour in warm room.</st +ep> <step>Knead again.</step> <step>Place in a bread baking tin.</step> <step>Cover with a cloth, and leave for one hour in warm room.</st +ep> <step>Bake in the oven at 180(degrees)C for 30 minutes.</step> </instructions> </recipe>

And here's the result:

Rate XML::Simple XML::Twig YAML::Syck Data::Dumper Sto +rable JSON::XS XML::Simple 422/s -- -24% -96% -97% + -99% -99% XML::Twig 556/s 32% -- -95% -96% + -99% -99% YAML::Syck 11622/s 2652% 1989% -- -11% + -81% -84% Data::Dumper 13039/s 2988% 2244% 12% -- + -79% -82% Storable 60964/s 14335% 10859% 425% 368% + -- -18% JSON::XS 74479/s 17535% 13289% 541% 471% + 22% --

In reply to Re^4: Creating Storable objects from the C by zwon
in thread Creating Storable objects from the C by zwon

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • Outside of code tags, you may need to use entities for some characters:
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.
  • Log In?
    Username:
    Password:

    What's my password?
    Create A New User
    Chatterbox?
    and the web crawler heard nothing...

    How do I use this? | Other CB clients
    Other Users?
    Others wandering the Monastery: (7)
    As of 2014-07-25 09:58 GMT
    Sections?
    Information?
    Find Nodes?
    Leftovers?
      Voting Booth?

      My favorite superfluous repetitious redundant duplicative phrase is:









      Results (170 votes), past polls