I chose the serialization functions for the database - bson. Faster serialize in> 1.5 times, json - in 3. And the result is less than all the others.
You can find it in the extension for MongoDB.
The results below.
For each iteration, the array and the object created from the array were processed. strlen1 and strlen2 are the lengths of the resulting strings, respectively.
array ( '_all' => array ( 'time' => 17.71448302269, 'N' => 40000, ), 'serialize' => array ( 'time' => 3.4848301410675, 'strlen1' => 1087, 'strlen2' => 1168, ), 'json' => array ( 'time' => 6.2529139518738, 'strlen1' => 950, 'strlen2' => 966, ), 'json_unesc' => array ( 'time' => 6.0889739990234, 'strlen1' => 950, 'strlen2' => 966, ), 'bson' => array ( 'time' => 1.8876740932465, 'strlen1' => 884, 'strlen2' => 884, ), )
UPD: Serialization and deserialization was tested.
igbinary here already:
'igbinary' => array ( 'time' => 4.2307059764862, 'strlen1' => 702, 'strlen2' => 724, ),
UPD: msgpack already without numbers, but it is more interesting. Little. 15% faster bson in serialization, and in size between bson and igbinary. But anpack is 2 times slower, for a total of 2x almost 1.5 times slower. Pluses are implementations for many languages.