This extension provides a high performance byte buffer implementation for PHP. Replacement for pack()
, unpack()
, and pmmp/BinaryUtils
- ByteBuf uses exponential growth for buffer size to prevent frequent memory allocation.
LE
&BE
performance is ~2x faster thanpack()
andunpack()
Comparison with pmmp/BinaryUtils
ByteBuf->read
andByteBuf->write
performance is ~2x faster- VarInt reading and writing performance is ~9x faster
- Triad reading and writing performance is ~3x faster
Comparison with pmmp/ext-encoding
ByteBuf->read
performance is ~1.5x faster
Self-explanatory, see bytebuf.stub.php and tests
- Reusable ByteBuf to reduce memory allocation
- More tests
- Make sure you have PHP development environment installed and downloaded the PHP Source Code. See: Windows, Linux
- Clone this repository to
/path/to/php-src/ext/bytebuf
- To build on Windows, you need to run terminal via
phpsdk-vs17-x64.bat
. Run the following commands:
cd /path/to/php-src
buildconf
./configure --enable-bytebuf (...other options)
make # For Linux
nmake # For Windows