-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #11 from charonlab/phpbench
Migrate to PHPBench for performance tests
- Loading branch information
Showing
17 changed files
with
188 additions
and
112 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
name: "Performance benchmark" | ||
|
||
on: | ||
pull_request: | ||
branches: | ||
- "*.x" | ||
paths: | ||
- composer.* | ||
- phpbench.json | ||
- src/** | ||
- tests/** | ||
push: | ||
branches: | ||
- "*.x" | ||
paths: | ||
- composer.* | ||
- phpbench.json | ||
- src/** | ||
- tests/** | ||
|
||
jobs: | ||
phpbench: | ||
name: "PHPBench" | ||
runs-on: "ubuntu-latest" | ||
|
||
strategy: | ||
matrix: | ||
php-version: | ||
- "8.3" | ||
|
||
steps: | ||
- uses: "actions/checkout@v4" | ||
with: | ||
fetch-depth: 0 | ||
- uses: "shivammathur/setup-php@v2" | ||
with: | ||
php-version: "${{ matrix.php-version }}" | ||
coverage: "pcov" | ||
ini-values: "zend.assertions=1, apc.enable_cli=1" | ||
- uses: "ramsey/composer-install@v3" | ||
- name: "Run PHPBench" | ||
run: "composer run phpbench" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
{ | ||
"$schema":"./vendor/phpbench/phpbench/phpbench.schema.json", | ||
|
||
"runner.bootstrap": "./vendor/autoload.php", | ||
"runner.path": "tests/Performance", | ||
"runner.progress": "plain", | ||
"runner.iterations": 20, | ||
"runner.revs": 1000, | ||
"runner.file_pattern": "*Bench.php", | ||
"report.generators": { | ||
|
||
"compressed": { | ||
"title": "Charon Container Benchmark Tests", | ||
"generator": "expression", | ||
"cols": [ "benchmark", "subject", "mem_peak", "mode", "mean", "best", "worst" ] | ||
} | ||
}, | ||
|
||
"core.extensions": [ | ||
"PhpBench\\Extensions\\XDebug\\XDebugExtension" | ||
] | ||
} |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
<?php | ||
|
||
/* | ||
* This file is part of the charonlab/charon-container. | ||
* | ||
* Copyright (C) 2023-2024 Charon Lab Development Team | ||
* | ||
* This software may be modified and distributed under the terms | ||
* of the MIT license. See the LICENSE.md file for details. | ||
*/ | ||
|
||
namespace Charon\Tests\Container\Performance; | ||
|
||
use Charon\Container\Container; | ||
use Charon\Container\ContainerInterface; | ||
|
||
class AbstractBenchCase | ||
{ | ||
/** @psalm-suppress PropertyNotSetInConstructor */ | ||
protected ContainerInterface $container; | ||
|
||
public function setup(): void { | ||
$this->container = new Container(); | ||
} | ||
|
||
public function tearDown(): void { | ||
unset($this->container); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
<?php | ||
|
||
/* | ||
* This file is part of the charonlab/charon-container. | ||
* | ||
* Copyright (C) 2023-2024 Charon Lab Development Team | ||
* | ||
* This software may be modified and distributed under the terms | ||
* of the MIT license. See the LICENSE.md file for details. | ||
*/ | ||
|
||
namespace Charon\Tests\Container\Performance\Cases; | ||
|
||
use Charon\Tests\Container\Performance\AbstractBenchCase; | ||
use Charon\Tests\Container\Performance\Stubs\FooBar; | ||
use PhpBench\Attributes\AfterMethods; | ||
use PhpBench\Attributes\Assert; | ||
use PhpBench\Attributes\BeforeMethods; | ||
|
||
class ContainerBench extends AbstractBenchCase | ||
{ | ||
#[BeforeMethods('setup')] | ||
#[AfterMethods('tearDown')] | ||
#[Assert('mode(variant.time.avg) < 5ms')] | ||
#[Assert('mode(variant.mem.real) < 10mb')] | ||
public function benchResolvePerformance(): void { | ||
$this->container->resolve(FooBar::class); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
<?php | ||
|
||
/* | ||
* This file is part of the charonlab/charon-container. | ||
* | ||
* Copyright (C) 2023-2024 Charon Lab Development Team | ||
* | ||
* This software may be modified and distributed under the terms | ||
* of the MIT license. See the LICENSE.md file for details. | ||
*/ | ||
|
||
namespace Charon\Tests\Container\Performance\Stubs; | ||
|
||
class Bar | ||
{ | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
<?php | ||
|
||
/* | ||
* This file is part of the charonlab/charon-container. | ||
* | ||
* Copyright (C) 2023-2024 Charon Lab Development Team | ||
* | ||
* This software may be modified and distributed under the terms | ||
* of the MIT license. See the LICENSE.md file for details. | ||
*/ | ||
|
||
namespace Charon\Tests\Container\Performance\Stubs; | ||
|
||
class Foo | ||
{ | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
<?php | ||
|
||
/* | ||
* This file is part of the charonlab/charon-container. | ||
* | ||
* Copyright (C) 2023-2024 Charon Lab Development Team | ||
* | ||
* This software may be modified and distributed under the terms | ||
* of the MIT license. See the LICENSE.md file for details. | ||
*/ | ||
|
||
namespace Charon\Tests\Container\Performance\Stubs; | ||
|
||
class FooBar | ||
{ | ||
public function __construct( | ||
public Foo $foo, | ||
public Bar $bar | ||
) { | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters