diff --git a/.gitattributes b/.gitattributes index 7161823..05ef60d 100644 --- a/.gitattributes +++ b/.gitattributes @@ -12,3 +12,4 @@ /phpunit.xml export-ignore /**/*Test.php export-ignore /**/Test** export-ignore +/**/*Bench.php export-ignore diff --git a/CHANGELOG.md b/CHANGELOG.md index 236b7f7..8bfee61 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -20,6 +20,7 @@ All Notable changes to `bakame/http-strucured-fields` will be documented in this ### Fixed - Test suite migrated to PHPUnit 10 +- Adding Benchmark test with PHPBench - Improve Collection immutability with method changes - **[BC Break]** `ParameterAccess` interface signature updated to use the `Value` interface instead of the `Item` implementation. - **[BC Break]** `MemberList::remove`, `MemberOrderedMap::remove` and `MemberOrderedMap::keys` methods are moved to their parent interface. diff --git a/composer.json b/composer.json index 00f850e..5f424df 100644 --- a/composer.json +++ b/composer.json @@ -34,7 +34,8 @@ "phpstan/phpstan-strict-rules": "^1.5.0", "phpstan/phpstan-phpunit": "^1.3.10", "phpstan/phpstan-deprecation-rules": "^1.1.2", - "phpunit/phpunit": "^10.0.15" + "phpunit/phpunit": "^10.0.15", + "phpbench/phpbench": "^1.2" }, "autoload": { "psr-4": { @@ -46,6 +47,7 @@ ] }, "scripts": { + "benchmark": "phpbench run --report=default", "phpcs": "PHP_CS_FIXER_IGNORE_ENV=1 php-cs-fixer fix --dry-run --diff -vvv --allow-risky=yes --ansi", "phpcs:fix": "php-cs-fixer fix -vvv --allow-risky=yes --ansi", "phpstan": "phpstan analyse -c phpstan.neon --ansi --xdebug --memory-limit 192M", @@ -53,7 +55,8 @@ "test": [ "@phpunit", "@phpstan", - "@phpcs" + "@phpcs", + "@benchmark" ] }, "scripts-descriptions": { diff --git a/phpbench.json b/phpbench.json new file mode 100644 index 0000000..b8c7a44 --- /dev/null +++ b/phpbench.json @@ -0,0 +1,7 @@ +{ + "$schema": "vendor/phpbench/phpbench/phpbench.schema.json", + "runner.bootstrap": "vendor/autoload.php", + "runner.path": ["src"], + "runner.file_pattern": "*Bench.php", + "runner.php_disable_ini": true +} diff --git a/src/ParserBench.php b/src/ParserBench.php new file mode 100644 index 0000000..339f349 --- /dev/null +++ b/src/ParserBench.php @@ -0,0 +1,40 @@ +