Skip to content

Instantly share code, notes, and snippets.

@parf
parf / igbinary-vs-msgpack.php
Last active May 9, 2022 18:12
msgpack vs igbinary comparison on 1500x1500 array. msgpack is ~30 times slower
<?php
ini_set('memory_limit', '32G');
// PARFS speed test
echo "PHP Version: ".phpversion()." @ ".gethostname()."\n";
$sz = function ($f, $fu, $data, $iterations=10, $gz=1) {
> php igbinary-fail.php
PHP7 can't igbinary_unserialize this data
[{"geo":[34.1989453,-118.597305]},{"geo":[37.9429522,-122.3900901]},{"geo":[37.677661,-122.4552162]},{"geo":[29.958529,-90.077003]},{"geo":[47.28,-122.76]},{"geo":[33.9202933,-117.4464354]},{"geo":[37.3,-121.98]},{"geo":[33.7463915,-117.8604472]},{"geo":[33.7513419,-117.9939921]},{"geo":[29.4627365,-95.357994]},{"geo":[29.6185208,-95.6090009]},{"geo":[38.9559442,-76.9455301]},{"geo":[37.6966286,-97.3413212]},{"geo":[37.3,-121.98]},{"geo":[37.3,-121.98]},{"geo":[37.3,-121.98]},{"geo":[42.2717443,-71.7588217]},{"geo":[37.7729273,-122.2143323]},{"geo":[42.8662,-85.8984]},{"geo":[42.3065441,-71.0824613]}]
igbinary_serialize($data) is the same as original-source;
* igbinary_serialize(json_encode(json_decode($original))) is not the same as igbinary_serialize($original);
* igbinary_serialize(unserialize(serialize($original))) is not the same as igbinary_serialize($original);
actual data is exactly the same: igbinary_unserialize(igbinary_serialize(ser