PHP5.5 serialization performance comparison. PHP5.5 comparison of three serialization performance methods: json_encode, serialize, and igbinary. Related tests have been conducted before. PHP5.5 is unavailable for the time being. this test compares the three serialization performance methods of PHP5.5.
Three serialization methods, json_encode, serialize, and igbinary, have been tested before. PHP5.5 has not been tested yet. this test is based on PHP5.5 and is a test case,
Http://blog.csdn.net/hguisu/article/details/7651730
The test cases are the same, but from this test home igbinary serialize test, as a comparison, you can refer
Http://www.ooso.net/archives/538
Running environment
PHP5.5 memory 16G 8 Core 2.0 GMHz
Performance & space size list
Test results using a small array
json :156serialize :222igbinary_serialize :123json_encode :0.02264404296875json_decode :0.052916049957275serialize :0.031183004379272unserialize :0.029985904693604Igbinary Serialize: 0.024919986724854Igbinary unSerialize: 0.019716024398804
To facilitate the comparison, put the test results of PHP5.3 below (igbinary was not tested before)
json :156serialize :222json_encode :0.1087498664856json_decode :0.12652111053467serialize :0.041656017303467unserialize :0.040987968444824
Test results using a large array
json :5350serialize :8590igbinary_serialize :2432json_encode :0.92639899253845json_decode :1.8222811222076serialize :1.3030271530151unserialize :1.1492691040039Igbinary Serialize: 0.95630598068237Igbinary unSerialize: 0.82603001594543
The following are the previous results (igbinary was not tested before)
json :5350serialize :8590json_encode :0.90479207038879json_decode :1.753741979599serialize :1.3566699028015unserialize :1.3003630638123
Summary:
Data:
1: After being upgraded to PHP5.5, the json, serialize, and igbinary formats are serialized without changing the size. This means that the object structure of these three formats has not changed, so they can be upgraded seamlessly.
2: In terms of space occupation, igbinary has obvious advantages in space saving. for example, for data of 8.6 k size in an array of json, the serialize method requires 2.4 k, while the igbinary method requires only k, almost 1/4 of the serialize mode.
Performance
1: for small data volumes, the performance of json and native serialize is improved compared with that of PHP5.3, while the performance decreases when processing large data volumes.
2: In terms of serialization, json_encode has the best performance, followed by igbinary. The two are almost the same, and the worst is native serialize. native serialize consumes about 1.4 times the performance of json and igbinary.
3: In terms of deserialization, igbinary is faster than the serialization process. of course, it is also the fastest, but this speed is also costly. For more information, see the final considerations.
4: Overall performance comparison: the overall performance is the sum of serialization and deserialization. simple comparison shows that json is the worst, followed by native serialize, and ibinary is the best way.
ComprehensiveWhether in terms of serialization performance or occupied space, igbinary is the best choice. However, using igbinary_unserialize is not free of charge. during the test, we found that when the igbinary_unserialize is called, passing illegal data will cause the entire php process to die.
child 19131 exited on signal 11 (SIGSEGV) after 1.844938 seconds from start 1.844938 seconds from start
It is estimated that in order to improve the performance of igbinary, no format verification is performed during unserialize, causing the entire process to exit unexpectedly. When using Redis, we first use the SERIALIZE_PHP method for serialization. to improve performance and reduce the waste of Redis space, we use the igbinary_serialize method. when switching, we accidentally step on this pitfall, this causes an error in the server response, which is directly 502, thanks to the daily environment.
Json_encode, serialize, and igbinary serialization methods. Related tests have been conducted before. PHP5.5 is not available for the moment. this test...