Skip to content

Commit

Permalink
Add phpbench
Browse files Browse the repository at this point in the history
  • Loading branch information
theofidry committed Nov 24, 2023
1 parent 8e1556a commit 141d55b
Show file tree
Hide file tree
Showing 217 changed files with 39,354 additions and 2 deletions.
34 changes: 34 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,11 @@ INFECTION_SRC := $(shell find src tests) phpunit.xml.dist
PHP_CS_FIXER_BIN = vendor-bin/php-cs-fixer/vendor/bin/php-cs-fixer
PHP_CS_FIXER = $(PHP_CS_FIXER_BIN)

PHPBENCH_BIN = vendor-bin/phpbench/vendor/bin/phpbench
PHPBENCH = $(PHPBENCH_BIN)
PHPBENCH_WITH_COMPACTORS_VENDOR_DIR = fixtures/bench/with-compactors/vendor
PHPBENCH_WITHOUT_COMPACTORS_VENDOR_DIR = fixtures/bench/without-compactors/vendor

WEBSITE_SRC := mkdocs.yaml $(shell find doc)
# This is defined in mkdocs.yaml#site_dir
WEBSITE_OUTPUT = dist/website
Expand Down Expand Up @@ -249,6 +254,15 @@ _infection: $(INFECTION_BIN) $(COVERAGE_XML_DIR) $(COVERAGE_JUNIT) vendor
_infection_ci: $(INFECTION_BIN) $(COVERAGE_XML_DIR) $(COVERAGE_JUNIT) vendor
$(INFECTION_CI)

.PHONY: phpbench
phpbench: ## Runs PHPBench
phpbench: $(PHPBENCH_BIN) $(PHPBENCH_WITH_COMPACTORS_VENDOR_DIR) $(PHPBENCH_WITHOUT_COMPACTORS_VENDOR_DIR)
$(MAKE) _phpbench

.PHONY: _phpbench
_phpbench:
$(PHPBENCH) run tests/Benchmark --report=default


#---------------------------------------------------------------------------

Expand Down Expand Up @@ -370,6 +384,18 @@ vendor-bin/php-cs-fixer/composer.lock: vendor-bin/php-cs-fixer/composer.json
@echo "$(ERROR_COLOR)$(@) is not up to date. You may want to run the following command:$(NO_COLOR)"
@echo "$$ composer bin php-cs-fixer update --lock && touch -c $(@)"

.PHONY: phpbench_install
phpbench_install: $(PHPBENCH_BIN)

$(PHPBENCH_BIN): vendor-bin/phpbench/vendor
touch -c $@
vendor-bin/phpbench/vendor: vendor-bin/phpbench/composer.lock $(COMPOSER_BIN_PLUGIN_VENDOR)
composer bin phpbench install
touch -c $@
vendor-bin/phpbench/composer.lock: vendor-bin/phpbench/composer.json
@echo "$(ERROR_COLOR)$(@) is not up to date. You may want to run the following command:$(NO_COLOR)"
@echo "$$ composer bin phpbench update --lock && touch -c $(@)"

.PHONY: infection_install
infection_install: $(INFECTION_BIN)

Expand Down Expand Up @@ -457,6 +483,14 @@ vendor-bin/requirement-checker/composer.lock: vendor-bin/requirement-checker/com
@echo "$(ERROR_COLOR)$(@) is not up to date. You may want to run the following command:$(NO_COLOR)"
@echo "$$ composer bin requirement-checker update --lock && touch -c $(@)"

$(PHPBENCH_WITH_COMPACTORS_VENDOR_DIR):
composer install --working-dir=$$(dirname $@)
touch -c $@

$(PHPBENCH_WITHOUT_COMPACTORS_VENDOR_DIR):
composer install --working-dir=$$(dirname $@)
touch -c $@

dist:
mkdir -p dist
touch dist/.gitkeep
Expand Down
2 changes: 2 additions & 0 deletions fixtures/bench/with-compactors/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
/.box_dump/
/vendor/
12 changes: 12 additions & 0 deletions fixtures/bench/with-compactors/box.json.dist
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"$schema": "../../../res/schema.json",

"main": "box.php",
"output": "../../../dist/bench/box.phar",

"directories-bin": ["../../../res/requirement-checker"],
"force-autodiscovery": true,

"dump-autoload": false,
"datetime": "release-date"
}
60 changes: 60 additions & 0 deletions fixtures/bench/with-compactors/box.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
#!/usr/bin/env php
<?php

declare(strict_types=1);

/*
* This file is part of the box project.
*
* (c) Kevin Herrera <[email protected]>
* Théo Fidry <[email protected]>
*
* This source file is subject to the MIT license that is bundled
* with this source code in the file LICENSE.
*/

namespace KevinGH\Box;

use Fidry\Console\Application\ApplicationRunner;
use Fidry\Console\IO;
use KevinGH\Box\Console\Application;
use KevinGH\Box\Console\OutputFormatterConfigurator;
use RuntimeException;
use function file_exists;
use function in_array;
use const PHP_EOL;
use const PHP_SAPI;

// See https://github.com/easysoft/phpmicro for the micro SAPI.
if (false === in_array(PHP_SAPI, ['cli', 'phpdbg', 'embed', 'micro'], true)) {
echo PHP_EOL.'Box may only be invoked from a command line, got "'.PHP_SAPI.'"'.PHP_EOL;

exit(1);
}

(static function (): void {
if (file_exists($autoload = __DIR__.'/../../../autoload.php')) {
// Is installed via Composer
include_once $autoload;

return;
}

if (file_exists($autoload = __DIR__.'/../vendor/autoload.php')) {
// Is installed locally
include_once $autoload;

return;
}

throw new RuntimeException('Unable to find the Composer autoloader.');
})();

register_aliases();
register_error_handler();

$io = IO::createDefault();
OutputFormatterConfigurator::configure($io);

$runner = new ApplicationRunner(new Application());
$runner->run($io);
114 changes: 114 additions & 0 deletions fixtures/bench/with-compactors/composer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,114 @@
{
"name": "humbug/box",
"description": "Fast, zero config application bundler with PHARs.",
"license": "MIT",
"keywords": [
"phar"
],
"authors": [
{
"name": "Kevin Herrera",
"email": "[email protected]",
"homepage": "http://kevin.herrera.io"
},
{
"name": "Théo Fidry",
"email": "[email protected]"
}
],
"require": {
"php": "^8.2",
"ext-iconv": "*",
"ext-mbstring": "*",
"ext-phar": "*",
"composer-plugin-api": "^2.2",
"amphp/parallel-functions": "^1.1",
"composer/semver": "^3.3.2",
"composer/xdebug-handler": "^3.0.3",
"fidry/console": "^0.6.0",
"fidry/filesystem": "^1.1",
"humbug/php-scoper": "^0.18.6",
"justinrainbow/json-schema": "^5.2.12",
"laravel/serializable-closure": "^1.2.2",
"nikic/iter": "^2.2",
"nikic/php-parser": "^4.15.2",
"phpdocumentor/reflection-docblock": "^5.3",
"phpdocumentor/type-resolver": "^1.7",
"psr/log": "^3.0",
"sebastian/diff": "^4.0",
"seld/jsonlint": "^1.9",
"seld/phar-utils": "^1.2",
"symfony/filesystem": "^6.1.5",
"symfony/finder": "^6.1.3",
"symfony/polyfill-iconv": "^1.28",
"symfony/polyfill-mbstring": "^1.28",
"symfony/process": "^6.1.3",
"symfony/var-dumper": "^6.1.6",
"webmozart/assert": "^1.11"
},
"require-dev": {
"bamarni/composer-bin-plugin": "^1.8.2",
"ergebnis/composer-normalize": "^2.29",
"fidry/makefile": "^1.0.1",
"mikey179/vfsstream": "^1.6.11",
"phpspec/prophecy": "^1.17",
"phpspec/prophecy-phpunit": "^2.0.2",
"phpunit/phpunit": "^9.5.26",
"symfony/phpunit-bridge": "^6.1.6",
"symfony/yaml": "^6.2",
"webmozarts/strict-phpunit": "^7.6"
},
"replace": {
"symfony/polyfill-php80": "*",
"symfony/polyfill-php81": "*"
},
"suggest": {
"ext-openssl": "To accelerate private key generation."
},
"minimum-stability": "dev",
"prefer-stable": true,
"autoload": {
"psr-4": {
"KevinGH\\Box\\": "src"
},
"files": [
"src/functions.php"
],
"exclude-from-classmap": [
"/Test/",
"vendor/humbug/php-scoper/vendor-hotfix"
]
},
"autoload-dev": {
"psr-4": {
"KevinGH\\Box\\": [
"fixtures",
"tests"
]
}
},
"bin": [
"bin/box"
],
"config": {
"allow-plugins": {
"bamarni/composer-bin-plugin": true,
"composer/package-versions-deprecated": false,
"ergebnis/composer-normalize": true
},
"platform": {
"php": "8.2"
},
"platform-check": false,
"sort-packages": true
},
"extra": {
"bamarni-bin": {
"bin-links": false,
"forward-command": false
},
"branch-alias": {
"dev-main": "4.x-dev"
}
}
}
Loading

0 comments on commit 141d55b

Please sign in to comment.