Skip to content

Instantly share code, notes, and snippets.

View rybakit's full-sized avatar

Eugene Leonovich rybakit

View GitHub Profile
<?php
const UTF8_REGEX = '/\A(?:
[\x00-\x7F]++ # ASCII
| [\xC2-\xDF][\x80-\xBF] # non-overlong 2-byte
| \xE0[\xA0-\xBF][\x80-\xBF] # excluding overlongs
| [\xE1-\xEC\xEE\xEF][\x80-\xBF]{2} # straight 3-byte
| \xED[\x80-\x9F][\x80-\xBF] # excluding surrogates
| \xF0[\x90-\xBF][\x80-\xBF]{2} # planes 1-3
| [\xF1-\xF3][\x80-\xBF]{3} # planes 4-15
@rybakit
rybakit / bench_swoole.php
Last active December 29, 2021 10:54
tarantool/client swoole
<?php
/**
* This file is part of the Tarantool Client package.
*
* (c) Eugene Leonovich <[email protected]>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
@rybakit
rybakit / Zend_bench.php.log
Last active February 14, 2019 13:34
php8 jit msgpack.php benchmarks
$ sapi/cli/php Zend/bench.php
------------------------
Total 0.497
$ sapi/cli/php -dextension_dir=`pwd`/modules -dzend_extension=opcache.so Zend/bench.php
------------------------
Total 0.488
$ sapi/cli/php -dextension_dir=`pwd`/modules -dzend_extension=opcache.so -dopcache.enable_cli=1 -dopcache.file_update_protection=0 -dopcache.jit_buffer_size=1M Zend/bench.php
------------------------
php -r '$exif=@exif_read_data("lc-bad-exif.jpg");print_r($exif);' > exif_read_data.log
@rybakit
rybakit / jobserver.lua
Created October 6, 2017 06:18
tarantool/queue config example
queue = require('queue')
local function start(config)
box.once('jobserver:v0.1.0', function()
local tube = queue.create_tube('default', 'fifottl', {if_not_exists = true})
end)
end
local function stop()
end
@rybakit
rybakit / output.txt
Last active January 23, 2017 08:41
PHP Serialization Benchmarks
\SKM\Benchmarks\Serialization\BooleanSerializationBench
benchSerializeJSON I9 P0 [μ Mo]/r: 0.201 0.195 (μs) [μSD μRSD]/r: 0.011μs 5.29%
benchSerializeJSON I9 P1 [μ Mo]/r: 0.202 0.196 (μs) [μSD μRSD]/r: 0.011μs 5.61%
benchDeserializeJSON I9 P0 [μ Mo]/r: 0.386 0.385 (μs) [μSD μRSD]/r: 0.002μs 0.48%
benchDeserializeJSON I9 P1 [μ Mo]/r: 0.447 0.410 (μs) [μSD μRSD]/r: 0.107μs 23.81%
benchSerializeNative I9 P0 [μ Mo]/r: 0.221 0.218 (μs) [μSD μRSD]/r: 0.009μs 4.18%
benchSerializeNative I9 P1 [μ Mo]/r: 0.221 0.218 (μs) [μSD μRSD]/r: 0.009μs 4.21%
benchDeserializeNative I9 P0 [μ Mo]/r: 0.441 0.431 (μs) [μSD μRSD]/r: 0.019μs 4.31%
benchDeserializeNative I9 P1 [μ Mo]/r: 0.441 0.430 (μs) [μSD μRSD]/r: 0.019μs 4.26%
@rybakit
rybakit / bench_concat_vs_interpol.php
Last active December 29, 2016 10:43
Bench php7 encapsed strings optimization
<?php
// https://blog.blackfire.io/php-7-performance-improvements-encapsed-strings-optimization.html
class Foobar
{
public function getVal1()
{
return rand(0, 1000);
}
<?php
const UTF8_REGEX = '/\A(?:
[\x00-\x7F]++ # ASCII
| [\xC2-\xDF][\x80-\xBF] # non-overlong 2-byte
| \xE0[\xA0-\xBF][\x80-\xBF] # excluding overlongs
| [\xE1-\xEC\xEE\xEF][\x80-\xBF]{2} # straight 3-byte
| \xED[\x80-\x9F][\x80-\xBF] # excluding surrogates
| \xF0[\x90-\xBF][\x80-\xBF]{2} # planes 1-3
| [\xF1-\xF3][\x80-\xBF]{3} # planes 4-15
@rybakit
rybakit / bench_gettype_vs_is.php
Created July 14, 2016 08:14
switch gettype vs if is_*
<?php
function switch_gettype($n, $value) {
for ($i = 0; $i < $n; ++$i) {
switch (\gettype($value)) {
case 'array': continue;
case 'string': continue;
case 'integer': continue;
case 'NULL': continue;
case 'boolean': continue;
<?php
function pack_cc($n) {
for ($i = 0; $i < $n; ++$i) {
$num = \pack('CC', 0xcc, 200);
}
}
function chr_cc($n) {
for ($i = 0; $i < $n; ++$i) {