Try MessagePack in PHP

Source: Internet
Author: User
ItslikeJSON. butfastandsmall. This sentence attracted me and I took a look. Official Website: msgpack.org official installation method dumb, msgpack directory does not have php Directory at all... only see csharp, erlang, go, java, ruby and other directories. Reference gitclonegithub. commsgpackmsgpack. gitcdmsgpa

Its like JSON. but fast and small. This sentence attracted me and I took a look. Official Website: http://msgpack.org official installation method dumb people, msgpack directory does not php Directory at all... only see csharp, erlang, go, java, ruby and other directories. Reference git clone https://github.com/msgpack/msgpack.git cd msgpa

It's like JSON. but fast and small.

This sentence attracted me and gave me a look.

Official Website: http://msgpack.org

The official installation method is confusing. There is no php Directory under the msgpack directory... only the directories such as csharp, erlang, go, java, and ruby are displayed.

Reference


Git clone https://github.com/msgpack/msgpack.git
Cd msgpack/php
Phpize
./Configure & make install



Still found in PHP official website Extension: http://pecl.php.net/package/msgpack
Last Updated:, yesterday's version.
Installation Process:

Wget http://pecl.php.net/get/msgpack-0.5.2.tgz
Tar zxf msgpack-0.5.2.tgz
Cd msgpack-0.5.2
/Usr/local/hx/php/bin/phpize
./Configure -- with-php-config =/usr/local/hx/php/bin/php-config
Make & make install


Add msgpack. so to php. ini, restart php, and complete the installation.

Start test:
$ Data = array (0 => 'abcdefhijklmnopqrstuvwxy', 1 => 'xiamen ', 'abc' => '123 ');

Msgpack_pack, json_encode, and serialize are respectively set to 50, 62, and 87.
Then execute the command 10000 times, respectively. The time consumed is 9.95 milliseconds, 17.45 milliseconds, and 8.85 milliseconds.
Unlocks 10000 executions, time consumed: 14.76 milliseconds, 23.93 milliseconds, 14.61 milliseconds

Msgpack has a performance of at least over json50%. Although it is similar to the speed of serialize, the space occupied by serialize is much higher.

In addition, the GBK program is convenient. msgpack_pack can also be used in Chinese. If json is used, it must be converted to UTF-8 in batches before json_encode can be used.
Tags-php, json

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.