note 100602 modified in function.serialize by danbrown

From: Date: Tue, 26 Oct 2010 14:15:23 +0000
Subject: note 100602 modified in function.serialize by danbrown
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-173469@lists.php.net to get a copy of this message
i did a benchmark between serialization and json_serialize and i found that serialize is 12% fast than json_encode (no tag, php 5.2.12). I used this array as a example of serialization (10'000 iterations) <?php $arr=array( "in"=>array("in1"=>"valin1","in2"=>506,"in33"=>"valin3") ,"out"=>array("in1"=>"valin1","in2"=>"valin2")); ?> and unserialize is 70% fast than json_decode. in conclusion: a) as expected, serialize is the fast way to.. ahem, serialize objects and array (at least for some complex cases). b) but json produce a smaller string (and is more standard). --was-- i did a benchmark between serialization and json_serialize and i found that serialize is 12% fast than json_encode (no tag, php 5.2.12). I used this array as a example of serialization (10'000 iterations) <? $arr=array( "in"=>array("in1"=>"valin1","in2"=>506,"in33"=>"valin3") ,"out"=>array("in1"=>"valin1","in2"=>"valin2")); ?> and unserialize is 70% fast than json_decode. in conclusion: a) as expected, serialize is the fast way to.. ahem, serialize objects and array (at least for some complex cases). b) but json produce a smaller string (and is more standard). http://php.net/manual/en/function.serialize.php

« previous php.notes (#173469) next »