2017 © Pedro Peláez
 

library msgpack-php

MessagePack with pure PHP fail over

image

bezier/msgpack-php

MessagePack with pure PHP fail over

  • Thursday, October 23, 2014
  • by t4g
  • Repository
  • 1 Watchers
  • 5 Stars
  • 204 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 5 Forks
  • 1 Open issues
  • 2 Versions
  • 1 % Grown

The README.md

MessagePack PHP

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++., (*1)

Composer

https://packagist.org/packages/bezier/msgpack-php, (*2)

Project

Please see: http://msgpack.org/, (*3)

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, (*4)

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., (*5)

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)., (*6)

[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%)

The Versions

23/10 2014

dev-master

9999999-dev

MessagePack with pure PHP fail over

  Sources   Download

The Requires

  • php >=5.4.0

 

23/10 2014

1.0.0

1.0.0.0

MessagePack with pure PHP fail over

  Sources   Download

The Requires

  • php >=5.4.0