Home > Backend Development > PHP Tutorial > Comparison of three serialization performance of PHP5.5_PHP tutorial

Comparison of three serialization performance of PHP5.5_PHP tutorial

WBOY
Release: 2016-07-13 10:11:03
Original
959 people have browsed it

Comparison of three serialization performance of PHP5.5

The three serialization methods of json_encode, serialize, and igbinary have been tested before. There are no tests for PHP5.5 yet. This test is based on PHP5.5, and the test case is,
http: //blog.csdn.net/hguisu/article/details/7651730 The test cases of
are the same, but this test is based on the test of igbinary serialize at home. For comparison, you can refer to
http://www. ooso.net/archives/538

Running environment
PHP5.5 memory 16G 8 core 2.0GMHz

Performance& Space size list

Using small array test results

json :156
serialize :222
igbinary_serialize :123
json_encode :0.02264404296875
json_decode :0.052916049957275
serialize :0.031183004379272
unserialize :0.029985904693604
Igbinary Serialize: 0.024919986724854
Igbinary unSerialize: 0.019716024398804
Copy after login

For the convenience of comparison, the previous test results of PHP5.3 are placed below (igbinary has not been tested before)

json :156
serialize :222
json_encode :0.1087498664856
json_decode :0.12652111053467
serialize :0.041656017303467
unserialize :0.040987968444824
Copy after login

Using large array test results

json :5350
serialize :8590
igbinary_serialize :2432
json_encode :0.92639899253845
json_decode :1.8222811222076
serialize :1.3030271530151
unserialize :1.1492691040039
Igbinary Serialize: 0.95630598068237
Igbinary unSerialize: 0.82603001594543
Copy after login

The following are the previous results (igbinary was not tested before)

json :5350
serialize :8590
json_encode :0.90479207038879
json_decode :1.753741979599
serialize :1.3566699028015
unserialize :1.3003630638123
Copy after login

Summary:
Data:
1: After upgrading to PHP5.5, after serializing in json, serialize, and igbinary, the size has not changed, indicating that the object structure of these three formats has not changed, so it can Seamless upgrades.
2: In terms of space usage, igbinary has obvious advantages in saving space. For example, in a json array of 5.4k data, the serialize method takes 8.6k, but using the igbinary method, it only takes 2.4k, which is almost 1/4 of the serialize method. .
Performance
1: When dealing with small data, the performance of json and native serialize has improved compared to the PHP5.3 version, but when processing large amounts of data, the performance has declined. .
2: In terms of serialization, json_encode has the best performance, followed by igbinary, which is almost the same. The worst is native serialize. The performance consumption of native serialize is about 1.4 times that of json and igbinary
3: In terms of deserialization, igbinary is faster than the serialization process, and of course it is the fastest, but this speed also comes at a cost, see the last note.
4: Overall performance comparison. The overall performance is the sum of serialization and deserialization. A simple comparison will find that json is the worst, followed by native serialize, and the best is ibinary.

Generally speaking, igbinary is the best choice in terms of serialization performance and space usage. However, using igbinary is not without cost. During the test, we found that when calling igbinary_unserialize, passing illegal data will cause the entire php process to die. The log

child 19131 exited on signal 11 (SIGSEGV) after  1.844938 seconds from start 1.844938 seconds from start
Copy after login
is probably because igbinary did not do anything when unserialize in order to improve performance. Related format verification caused the entire process to exit abnormally. When using Redis, we first used the SERIALIZE_PHP method for serialization. In order to improve performance and reduce the waste of Redis space, we used the igbinary_serialize method. When we switched, we accidentally stepped on this pit, causing the server to respond with an error, directly 502. Fortunately, in the daily environment superior.

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/931650.htmlTechArticleComparison of the three serialization performance of PHP5.5 json_encode, serialize, and igbinary three serialization methods, which have been available before I have passed relevant tests. There is currently no test for PHP5.5. This test...
Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template