Skip to content

Instantly share code, notes, and snippets.

View SerafimArts's full-sized avatar
❓
wazzup?

Kirill Nesmeyanov SerafimArts

❓
wazzup?
View GitHub Profile
@SerafimArts
SerafimArts / bench.txt
Created August 5, 2026 13:35
PhpDoc Benchmarks
benchColdStart10b
+---------------+---------+----------+----------+----------+--------+
| benchmark | memory | min | max | mode | rstdev |
+---------------+---------+----------+----------+----------+--------+
| HoaBench | 1.847mb | 9.080ms | 9.434ms | 9.131ms | ±1.35% |
| PhplrtV3Bench | 1.309mb | 10.859ms | 11.309ms | 10.925ms | ±1.43% |
| PhplrtV4Bench | 1.292mb | 14.693ms | 15.113ms | 14.808ms | ±0.87% |
| PhpStanBench | 1.269mb | 6.191ms | 6.542ms | 6.275ms | ±1.75% |
| PsalmBench | 4.244mb | 25.389ms | 26.818ms | 25.588ms | ±1.92% |
+---------------+---------+----------+----------+----------+--------+
$ php .\libs\component\compiler\bin\boson compile -vvv
· Pack an application
↳ in Boson\Component\Compiler\Workflow\PackWorkflow::__invoke()
· Prepare build files
↳ in Boson\Component\Compiler\Workflow\PrepareWorkflow::__invoke()
· Create ".\build" directory
↳ in Boson\Component\Compiler\Workflow\Task\CreateDirectoryTask::__invoke()
· Apply write permissions to ".\build"
↳ in Boson\Component\Compiler\Workflow\Task\ApplyPermissionsTask::__invoke()
Applied write permissions
@SerafimArts
SerafimArts / backslash.php
Last active August 11, 2026 15:12
Why do you need to put a backslash before PHP functions?
<?php
namespace Example;
$a = 23;
\is_null($a);
@SerafimArts
SerafimArts / Headers.php
Last active August 28, 2025 20:58
PHP Memory Map Visualization
<?php
declare(strict_types=1);
namespace Serafim\MemProf\Zend;
use FFI\Contracts\Preprocessor\Exception\DirectiveDefinitionExceptionInterface;
use FFI\Contracts\Preprocessor\Exception\PreprocessorExceptionInterface;
use FFI\Contracts\Preprocessor\PreprocessorInterface;
use FFI\Preprocessor\Preprocessor;
<?php
/**
* @template TArgStart
* @template TArgResume
* @template TArgReturn
* @template TArgSuspend
*
* @param \Fiber<TArgStart, TArgResume, TArgReturn, TArgSuspend> $fiber
* @param TArgStart ...$args
* @return \Generator<array-key, TArgResume, TArgReturn, TArgSuspend>
@SerafimArts
SerafimArts / 1.out.txt
Created October 14, 2022 14:47
bin pack/unpack
benchInt8
+-----------+------+---------+---------+
| benchmark | set | mode | rstdev |
+-----------+------+---------+---------+
| PackBench | raw | 0.972μs | ±22.36% |
| PackBench | pack | 1.336μs | ±25.69% |
+-----------+------+---------+---------+
benchUInt8
+-----------+------+---------+---------+
@SerafimArts
SerafimArts / WriteBench.php
Last active April 22, 2022 11:56
Shared Memory Benchmarks
<?php
namespace Bench;
use PhpBench\Attributes\BeforeMethods;
use PhpBench\Attributes\Iterations;
use PhpBench\Attributes\Revs;
use PhpBench\Attributes\Warmup;
#[Revs(100000), Warmup(2), Iterations(5)]
<?php
class Example
{
public function __construct(
public ?string $value = null,
) {
}
}
/** @var Example $object */
<?php
function file_get_contents(string $pathname): string
{
$result = '';
$fp = fopen($pathname, 'rb');
while (!feof($fp)) {
$chunk = 1024;
Fiber::getCurrent() && ($chunk = (Fiber::suspend() ?: 1024));
@SerafimArts
SerafimArts / example-1.php
Last active April 17, 2022 10:47
phpwtf-1
<?php
$variable = 23;
[$query, $params] = sql(fn() => <<<SQL
SELECT * FROM users WHERE id = ${yield $variable} OR id = ${yield 42}
SQL);
var_dump($query, $params);
//