This benchmark shows the performance of the PHP serialisation functions and also payload size.
- Native
json_encode()
andjson_decode()
functions - Native
serialize()
andunserialize()
functions - Igbinary extension
- Valinor
- Protobuf
- Laravel SerializableClosure
- Symfony Serializer Component.
php app.php bench:serializers --iterations=10000
Data Encoding
------- ---------------------- ---------------------- ---------------------- ---------------------- ------------------------- -------------------------- ---------------------- ----------------------- ------------------------ ---------------------- --------------------------- ----------------------------
# JSON array JSON object Ig Binary array Ig Binary object Native serializer array Native serializer object Protobuf object Symfony array Symfony object Valinor array SerializableClosure array SerializableClosure object
------- ---------------------- ---------------------- ---------------------- ---------------------- ------------------------- -------------------------- ---------------------- ----------------------- ------------------------ ---------------------- --------------------------- ----------------------------
min 0.00092 ms - 0 bytes 0.00097 ms - 0 bytes 0.00108 ms - 0 bytes 0.00122 ms - 0 bytes 0.00089 ms - 0 bytes 0.00105 ms - 0 bytes 0.00059 ms - 0 bytes 0.0203 ms - 0 bytes 0.10181 ms - 0 bytes 0.00098 ms - 0 bytes 0.00997 ms - 0 bytes 0.03151 ms - 0 bytes
max 0.13357 ms - 0 bytes 0.00183 ms - 0 bytes 0.00667 ms - 0 bytes 0.00922 ms - 0 bytes 0.00447 ms - 0 bytes 0.00344 ms - 0 bytes 0.0088 ms - 0 bytes 0.32826 ms - 2.00 MB 0.17658 ms - 0 bytes 0.00422 ms - 0 bytes 0.03579 ms - 0 bytes 0.12458 ms - 0 bytes
avg 0.001 ms - 0 bytes 0.00106 ms - 0 bytes 0.00115 ms - 0 bytes 0.0019 ms - 0 bytes 0.00096 ms - 0 bytes 0.00111 ms - 0 bytes 0.00063 ms - 0 bytes 0.02103 ms - 0 bytes 0.10659 ms - 0 bytes 0.00106 ms - 0 bytes 0.01023 ms - 0 bytes 0.03221 ms - 0 bytes
total 5.48794 ms - 0 bytes 4.15794 ms - 0 bytes 4.83834 ms - 2.00 MB 4.944 ms - 0 bytes 3.98199 ms - 0 bytes 4.29533 ms - 0 bytes 3.58858 ms - 0 bytes 25.34349 ms - 2.00 MB 112.33992 ms - 0 bytes 5.75869 ms - 0 bytes 14.06173 ms - 0 bytes 37.0032 ms - 0 bytes
------- ---------------------- ---------------------- ---------------------- ---------------------- ------------------------- -------------------------- ---------------------- ----------------------- ------------------------ ---------------------- --------------------------- ----------------------------
Order - 3 - - 4 - - 7 - - 8 - - 2 - - 6 - - 1 - - 10 - - 12 - - 5 - - 9 - - 11 -
------- ---------------------- ---------------------- ---------------------- ---------------------- ------------------------- -------------------------- ---------------------- ----------------------- ------------------------ ---------------------- --------------------------- ----------------------------
Data Decoding
------- ---------------------- ---------------------- ---------------------- ---------------------- ------------------------- -------------------------- ---------------------- ----------------------- ----------------------- ------------------------ --------------------------- ----------------------------
# JSON array JSON object Ig Binary array Ig Binary object Native serializer array Native serializer object Protobuf object Symfony array Symfony object Valinor array SerializableClosure array SerializableClosure object
------- ---------------------- ---------------------- ---------------------- ---------------------- ------------------------- -------------------------- ---------------------- ----------------------- ----------------------- ------------------------ --------------------------- ----------------------------
min 0.00261 ms - 0 bytes 0.0026 ms - 0 bytes 0.00119 ms - 0 bytes 0.00198 ms - 0 bytes 0.00133 ms - 0 bytes 0.00224 ms - 0 bytes 0.00137 ms - 0 bytes 0.06613 ms - 0 bytes 0.06661 ms - 0 bytes 0.20272 ms - 0 bytes 0.01709 ms - 0 bytes 0.03706 ms - 0 bytes
max 0.01227 ms - 0 bytes 0.00535 ms - 0 bytes 0.03775 ms - 0 bytes 0.02017 ms - 0 bytes 0.12396 ms - 0 bytes 0.1068 ms - 0 bytes 0.02317 ms - 0 bytes 0.75286 ms - 0 bytes 0.16183 ms - 0 bytes 1.88834 ms - 0 bytes 0.26208 ms - 0 bytes 0.16979 ms - 0 bytes
avg 0.00281 ms - 0 bytes 0.00304 ms - 0 bytes 0.0015 ms - 0 bytes 0.00232 ms - 0 bytes 0.00225 ms - 0 bytes 0.00268 ms - 0 bytes 0.00142 ms - 0 bytes 0.06902 ms - 0 bytes 0.06898 ms - 0 bytes 0.21545 ms - 0 bytes 0.01785 ms - 0 bytes 0.04083 ms - 0 bytes
total 6.1935 ms - 0 bytes 6.10782 ms - 0 bytes 4.66907 ms - 0 bytes 5.49897 ms - 0 bytes 5.92023 ms - 0 bytes 6.31746 ms - 0 bytes 4.70763 ms - 0 bytes 76.47717 ms - 0 bytes 74.49863 ms - 0 bytes 228.47132 ms - 0 bytes 22.71963 ms - 0 bytes 45.79335 ms - 0 bytes
------- ---------------------- ---------------------- ---------------------- ---------------------- ------------------------- -------------------------- ---------------------- ----------------------- ----------------------- ------------------------ --------------------------- ----------------------------
Order - 6 - - 7 - - 2 - - 4 - - 3 - - 5 - - 1 - - 11 - - 10 - - 12 - - 8 - - 9 -
------- ---------------------- ---------------------- ---------------------- ---------------------- ------------------------- -------------------------- ---------------------- ----------------------- ----------------------- ------------------------ --------------------------- ----------------------------
Data Size in Bytes
+------------+-------------+-----------------+------------------+-------------------------+--------------------------+-----------------+---------------+----------------+---------------+---------------------------+----------------------------+
| JSON array | JSON object | Ig Binary array | Ig Binary object | Native serializer array | Native serializer object | Protobuf object | Symfony array | Symfony object | Valinor array | SerializableClosure array | SerializableClosure object |
+------------+-------------+-----------------+------------------+-------------------------+--------------------------+-----------------+---------------+----------------+---------------+---------------------------+----------------------------+
| 430 | 430 | 348 | 482 | 635 | 848 | 193 | 430 | 430 | 430 | 961 | 1174 |
+------------+-------------+-----------------+------------------+-------------------------+--------------------------+-----------------+---------------+----------------+---------------+---------------------------+----------------------------+