bezier/msgpack-php
Composer 安装命令:
composer require bezier/msgpack-php
包简介
MessagePack with pure PHP fail over
README 文档
README
The purpose of this project is to implement MessagePack serialization with PHP failover. This might be useful for someone unable to install php-modules, or using HipHop to compile PHP as C++.
Composer
https://packagist.org/packages/bezier/msgpack-php
Project
Please see: http://msgpack.org/
Example
use CharStream;
$hole = "Light"
$pack = msgpack_pack($hole);
if ( msgpack_unpage($pack) === $hole ) {
echo "The hole is lit.";
}
Caveats
- Only msgpack_pack() and msgpack_unpack() are defined.
- It's only tested on little endian architecture, but should work on big endian as well, please test it if able.
- The uint64 and int64 types probably requires 64-bit systems to work
- It uses is_x() to select the type, do your casts before using the functions
- Unlike the official lib you can't pack objects. If you know how to do this please fork.
- It will always pack integers into the least amount of bits possible, and will prefer unsigned.
Benchmark
Based on msgpack/php/benchmark.php
As you can see the pure PHP implementation (msgpack-php) is quite slow compared with the great php-extension msgpack has created. However when msgpack-php is compiled using HipHop (msgpack-hphp) the performance difference is much less, with msgpack-hphp even beating msgpack in this particular benchmark a few places, perhaps due to the fact that the benchmark itself is compiled with HipHop as well.
The timing values are average seconds sampled 10 times with 10.000 iterations each. Percentages are relative to normal php serialize() (not HipHop's version).
[integer ] default json igbinary msgpack msgpack-php msgpack-hphp
status : OK OK OK OK OK OK
serialize : 0.0105 (100%) 0.0090 ( 85%) 0.0089 ( 84%) 0.0093 ( 88%) 0.0550 ( 523%) 0.0051 ( 57%)
unserialize: 0.0089 (100%) 0.0119 (134%) 0.0088 ( 99%) 0.0090 (101%) 0.0985 (1110%) 0.0208 (234%)
size : 12 (100%) 9 ( 75%) 9 ( 75%) 5 ( 41%) 5 ( 41%) 5 ( 41%)
[double ] default json igbinary msgpack msgpack-php msgpack-hphp
status : OK OK OK OK OK OK
serialize : 0.0323 (100%) 0.0132 ( 40%) 0.0092 ( 28%) 0.0094 ( 28%) 0.0740 (229%) 0.0074 ( 23%)
unserialize: 0.0221 (100%) 0.0124 ( 56%) 0.0085 ( 38%) 0.0089 ( 40%) 0.1151 (521%) 0.0217 ( 98%)
size : 54 (100%) 15 ( 27%) 13 ( 24%) 9 ( 16%) 9 ( 16%) 9 ( 16%)
[string ] default json igbinary msgpack msgpack-php msgpack-hphp
status : OK OK OK OK OK OK
serialize : 0.0104 (100%) 0.0123 (118%) 0.0092 ( 88%) 0.0096 ( 91%) 0.0728 ( 700%) 0.0067 ( 64%)
unserialize: 0.0095 (100%) 0.0153 (160%) 0.0093 ( 97%) 0.0097 (101%) 0.1469 (1543%) 0.0301 (316%)
size : 40 (100%) 34 ( 85%) 38 ( 95%) 35 ( 87%) 35 ( 87%) 35 ( 87%)
[array ] default json igbinary msgpack msgpack-php msgpack-hphp
status : OK OK OK OK OK OK
serialize : 0.0183 (100%) 0.0297 (162%) 0.0222 (121%) 0.0134 ( 73%) 0.5567 (3042%) 0.0432 (236%)
unserialize: 0.0174 (100%) 0.0363 (207%) 0.0171 ( 98%) 0.0170 ( 97%) 0.7823 (4483%) 0.1665 (957%)
size : 226 (100%) 176 ( 77%) 186 ( 82%) 176 ( 77%) 176 ( 77%) 176 ( 77%)
[array ] default json igbinary msgpack msgpack-php msgpack-hphp
status : OK OK OK OK OK OK
serialize : 0.0199 (100%) 0.0481 (242%) 0.0306 (153%) 0.0148 ( 74%) 0.8513 (4285%) 0.0763 ( 383%)
unserialize: 0.0231 (100%) 0.0583 (252%) 0.0202 ( 87%) 0.0248 (107%) 1.4168 (6134%) 0.3156 (1366%)
size : 406 (100%) 351 ( 86%) 346 ( 85%) 351 ( 86%) 351 ( 86%) 351 ( 86%)
bezier/msgpack-php 适用场景与选型建议
bezier/msgpack-php 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 232 次下载、GitHub Stars 达 5, 最近一次更新时间为 2014 年 10 月 23 日, 在 PHP 生态内属于活跃度较高的组件。
我们在过去多个企业项目中使用过 bezier/msgpack-php 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 bezier/msgpack-php 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
统计信息
- 总下载量: 232
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 5
- 点击次数: 24
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: Unknown
- 更新时间: 2014-10-23