note 103761 added to function.serialize
| From: | tickthokk at gmail dot com | Date: | Mon, 02 May 2011 18:39:55 +0000 |
| Subject: | note 103761 added to function.serialize | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-179345@lists.php.net to get a copy of this message | ||
On the topic of serialization, the comments seemed split on which was faster: serialize() or
json_encode().
I used an array with a serialized strlen() of 1604.
At 5,000 itterations, serialize won over (by .0001 seconds). At 50,000 itterations, serialize still
won. I then tested it with the suggested gzcompress() and base64_encode() combo. Both times
json_encode won; first by .25 seconds, and second (at 50k) 2.85 seconds.
However, that's only half the battle. Please take into consideration the difference between
unserialize() and json_decode(). In every instance, unserialize() was always faster. In the 5k
test, it was faster by .22 seconds (.13 with compression). In the 50k test, it was faster by 2.4
seconds (1.8 with compression).
Even if serialize() has it's downfalls, unserialize() balances that out.
----
Server IP: 69.147.83.197
Probable Submitter: 76.193.254.203
----
Manual Page -- http://www.php.net/manual/en/function.serialize.php
Edit -- https://master.php.net/note/edit/103761
Del: integrated -- https://master.php.net/note/delete/103761/integrated
Del: useless -- https://master.php.net/note/delete/103761/useless
Del: bad code -- https://master.php.net/note/delete/103761/bad+code
Del: spam -- https://master.php.net/note/delete/103761/spam
Del: non-english -- https://master.php.net/note/delete/103761/non-english
Del: in docs -- https://master.php.net/note/delete/103761/in+docs
Del: other reasons-- https://master.php.net/note/delete/103761
Reject -- https://master.php.net/note/reject/103761
Search -- https://master.php.net/manage/user-notes.php