Its like JSON. but fast and small. 这句吸引了我,去瞧了下。 官网:http://msgpack.org 官方的安装方法忽悠人,msgpack目录下根本没php目录...只看到csharp,erlang,go,java,ruby等目录。 引用 git clone https://github.com/msgpack/msgpack.git cd msgpa
It's like JSON. but fast and small.
这句吸引了我,去瞧了下。
官网:http://msgpack.org
官方的安装方法忽悠人,msgpack目录下根本没php目录...只看到csharp,erlang,go,java,ruby等目录。
引用
git clone https://github.com/msgpack/msgpack.git
cd msgpack/php
phpize
./configure && make && make install
还是在PHP官网扩展找到了:http://pecl.php.net/package/msgpack
最后更新时间:2012-09-14,昨天的版本。
附安装过程:
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
然后把msgpack.so加到php.ini里,重启php,完成安装。
开始测试:
$data = array(0=>'abcdefghijklmnopqrstuvwxyz',1=>'厦门','abc'=>'1234567890');
分别对其msgpack_pack,json_encode,serialize,长度为:50,62,87
然后分别执行10000次,耗时:9.95 毫秒,17.45 毫秒,8.85 毫秒
解开执行10000次,耗时:14.76 毫秒,23.93 毫秒,14.61 毫秒
msgpack的性能至少超过json50%,虽然和serialize其实速度差不多,但serialize占用空间明显比较多。
另外,GBK的程序方便了,中文也可以msgpack_pack,用json的话还要批量转换成utf-8之后才能json_encode。
Tags - php , json


Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

Dreamweaver Mac version
Visual web development tools

EditPlus Chinese cracked version
Small size, syntax highlighting, does not support code prompt function

Atom editor mac version download
The most popular open source editor

VSCode Windows 64-bit Download
A free and powerful IDE editor launched by Microsoft

SublimeText3 Mac version
God-level code editing software (SublimeText3)