<?xml version="1.0" encoding="windows-1252"?>
<node id="881812" title="Re^5: Storable( Double size not compatible in Storable) compatible) [benchmark]" created="2011-01-12 01:45:57" updated="2011-01-12 01:45:57">
<type id="11">
note</type>
<author id="321512">
andreas1234567</author>
<data>
<field name="doctext">
Then how do you, Anonymous Monk, explain why [mod://JSON::XS] is considerably faster than [mod://Storable] in this example:
&lt;c&gt;
# Benchmark

use warnings;
use strict;

use Benchmark qw(cmpthese);
use Storable qw(freeze thaw);
use JSON::XS;

my $hashref = { one =&gt; 1, two =&gt; 2, three =&gt; 3, four =&gt; 4, five =&gt; 5 };
my @array = (1 .. 1000);

cmpthese(
  -1,
  {
    'storable-hashref' =&gt; sub {
      my $foo = thaw(freeze($hashref));
    },
    'storable-arrayref' =&gt; sub {
      my $bar = thaw(freeze(\@array));
    },
    'json-xs-hashref' =&gt; sub {
      my $foo = decode_json(encode_json($hashref));
    },
    'json-xs-arrayref' =&gt; sub {
      my $bar = decode_json(encode_json(\@array));
    },
  }
);

__END__
&lt;/c&gt;
&lt;c&gt;$ perl -wl bm_storable_vs_json.pl
                      Rate storable-arrayref json-xs-arrayref storable-hashref json-xs-hashref
storable-arrayref   6222/s                --             -31%             -84%            -99%
json-xs-arrayref    8967/s               44%               --             -77%            -98%
storable-hashref   38280/s              515%             327%               --            -92%
json-xs-hashref   501851/s             7965%            5497%            1211%              --
$ 

&lt;/c&gt;

&lt;!-- Node text goes above. Div tags should contain sig only --&gt;
&lt;div class="pmsig"&gt;&lt;div class="pmsig-321512"&gt;
&lt;small&gt;
--&lt;br&gt;
No matter how great and destructive your problems may seem now, remember, you've probably only seen the tip of them. &lt;a href="http://www.despair.com/viewall.html"&gt;&amp;#91;1&amp;#93;&lt;/a&gt;
&lt;/small&gt;
&lt;/div&gt;&lt;/div&gt;</field>
<field name="root_node">
881140</field>
<field name="parent_node">
881274</field>
</data>
</node>
