-
Notifications
You must be signed in to change notification settings - Fork 555
Introduce PHPBench and move performance tests from AnalyserIntegrationTest to RegressionBench #5200
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
9289b65
fa1afb3
2902fcf
ca8dd2a
3024c44
1859b17
0c94d28
1710adb
7e6e94d
0f1f480
d92d73b
bc282bc
e4155d5
77838bf
02f1a86
70788c8
5fb14ad
cd74f0d
50b0f2f
081f445
1be0d93
00f0ba7
e8787d0
2cb623a
2e011a5
1c473c4
f9e97eb
e852e8f
98b76f0
753fecf
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,95 @@ | ||
| name: "Benchmark" | ||
|
|
||
| on: | ||
| pull_request: | ||
| paths-ignore: | ||
| - 'compiler/**' | ||
| - 'apigen/**' | ||
| - 'changelog-generator/**' | ||
| - 'issue-bot/**' | ||
| push: | ||
| branches: | ||
| - "2.1.x" | ||
| paths-ignore: | ||
| - 'compiler/**' | ||
| - 'apigen/**' | ||
| - 'changelog-generator/**' | ||
| - 'issue-bot/**' | ||
|
|
||
| concurrency: | ||
| group: bench-${{ github.head_ref || github.run_id }} | ||
| cancel-in-progress: true | ||
|
|
||
| permissions: | ||
| contents: read | ||
|
|
||
| jobs: | ||
| baseline: | ||
| name: "Baseline" | ||
| runs-on: ubuntu-latest | ||
| timeout-minutes: 60 | ||
|
|
||
| steps: | ||
| - name: Harden the runner (Audit all outbound calls) | ||
| uses: step-security/harden-runner@5ef0c079ce82195b2a36a210272d6b661572d83e # v2.14.2 | ||
| with: | ||
| egress-policy: audit | ||
|
|
||
| - name: "Checkout base branch" | ||
| uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4.3.1 | ||
|
|
||
| - name: "Install PHP" | ||
| uses: "shivammathur/setup-php@44454db4f0199b8b9685a5d763dc37cbf79108e1" # v2 | ||
| with: | ||
| coverage: "none" | ||
| php-version: "8.5" | ||
| tools: pecl | ||
| extensions: ds,mbstring | ||
| ini-file: development | ||
| ini-values: memory_limit=-1 | ||
|
|
||
| - uses: "ramsey/composer-install@3cf229dc2919194e9e36783941438d17239e8520" # v3 | ||
|
||
| - uses: "ramsey/composer-install@3cf229dc2919194e9e36783941438d17239e8520" # v3 | ||
Check warningCode scanning / zizmor detects commit SHAs that don't match their version comment tags Warning
detects commit SHAs that don't match their version comment tags
|
||
| with: | ||
| working-directory: "tests/" | ||
|
|
||
| - name: "Run phpbench baseline" | ||
| run: "tests/vendor/bin/phpbench run --dump-file=tests/bench/storage/baseline.xml" | ||
|
|
||
| - name: "Upload baseline artifact" | ||
| uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4 | ||
| with: | ||
| name: phpbench-baseline | ||
| path: tests/bench/storage/baseline.xml | ||
|
|
||
| test: | ||
| name: "Test" | ||
| runs-on: ubuntu-latest | ||
| timeout-minutes: 60 | ||
|
|
||
| steps: | ||
| - name: Harden the runner (Audit all outbound calls) | ||
| uses: step-security/harden-runner@5ef0c079ce82195b2a36a210272d6b661572d83e # v2.14.2 | ||
| with: | ||
| egress-policy: audit | ||
|
|
||
| - name: "Checkout" | ||
| uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4.3.1 | ||
|
Comment on lines
+76
to
+77
Check warningCode scanning / zizmor credential persistence through GitHub Actions artifacts Warning
credential persistence through GitHub Actions artifacts
|
||
|
|
||
| - name: "Install PHP" | ||
| uses: "shivammathur/setup-php@44454db4f0199b8b9685a5d763dc37cbf79108e1" # v2 | ||
| with: | ||
| coverage: "none" | ||
| php-version: "8.5" | ||
| tools: pecl | ||
| extensions: ds,mbstring | ||
| ini-file: development | ||
| ini-values: memory_limit=-1 | ||
|
|
||
| - uses: "ramsey/composer-install@3cf229dc2919194e9e36783941438d17239e8520" # v3 | ||
|
||
| - uses: "ramsey/composer-install@3cf229dc2919194e9e36783941438d17239e8520" # v3 | ||
Check warningCode scanning / zizmor detects commit SHAs that don't match their version comment tags Warning
detects commit SHAs that don't match their version comment tags
|
||
| with: | ||
| working-directory: "tests/" | ||
|
|
||
| - name: "Run phpbench test" | ||
| run: "tests/vendor/bin/phpbench run --file=tests/bench/storage/baseline.xml --report=aggregate" | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -13,3 +13,4 @@ | |
| /tests/PHPStan/Reflection/data/golden/ | ||
| tmp/.memory_limit | ||
| e2e/bashunit | ||
| /.phpbench | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| { | ||
| "$schema":"./tests/vendor/phpbench/phpbench/phpbench.schema.json", | ||
| "runner.bootstrap": "vendor/autoload.php", | ||
| "runner.path": "tests/bench", | ||
| "runner.file_pattern": "*Bench.php", | ||
| "storage.xml_storage_path": "tests/bench/storage" | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,81 @@ | ||
| <?php declare(strict_types = 1); | ||
|
|
||
| namespace PHPStan\Testing; | ||
|
|
||
| use PHPStan\DependencyInjection\Container; | ||
| use PHPStan\DependencyInjection\ContainerFactory; | ||
| use PHPStan\File\FileHelper; | ||
| use PHPStan\Internal\DirectoryCreator; | ||
| use PHPStan\Internal\DirectoryCreatorException; | ||
| use RuntimeException; | ||
| use function array_merge; | ||
| use function hash; | ||
| use function implode; | ||
| use function sys_get_temp_dir; | ||
| use const PHP_VERSION_ID; | ||
|
|
||
| trait PHPStanTestCaseTrait | ||
| { | ||
|
|
||
| /** @var array<string, Container> */ | ||
| private static array $containers = []; | ||
|
|
||
| public static function getContainer(): Container | ||
| { | ||
| $additionalConfigFiles = [__DIR__ . '/TestCase.neon']; | ||
| foreach (static::getAdditionalConfigFiles() as $configFile) { | ||
| $additionalConfigFiles[] = $configFile; | ||
| } | ||
| $cacheKey = hash('sha256', implode("\n", $additionalConfigFiles)); | ||
|
|
||
| if (!isset(self::$containers[$cacheKey])) { | ||
| $tmpDir = sys_get_temp_dir() . '/phpstan-tests'; | ||
| try { | ||
| DirectoryCreator::ensureDirectoryExists($tmpDir, 0777); | ||
| } catch (DirectoryCreatorException $e) { | ||
| throw new RuntimeException($e->getMessage(), previous: $e); | ||
| } | ||
|
|
||
| $rootDir = __DIR__ . '/../..'; | ||
| $fileHelper = new FileHelper($rootDir); | ||
| $rootDir = $fileHelper->normalizePath($rootDir, '/'); | ||
| $containerFactory = new ContainerFactory($rootDir); | ||
| $container = $containerFactory->create($tmpDir, array_merge([ | ||
| $containerFactory->getConfigDirectory() . '/config.level8.neon', | ||
| ], $additionalConfigFiles), []); | ||
| self::$containers[$cacheKey] = $container; | ||
|
|
||
| foreach ($container->getParameter('bootstrapFiles') as $bootstrapFile) { | ||
| (static function (string $file) use ($container): void { | ||
| require_once $file; | ||
| })($bootstrapFile); | ||
| } | ||
|
|
||
| if (PHP_VERSION_ID >= 80000) { | ||
| require_once __DIR__ . '/../../stubs/runtime/Enum/UnitEnum.php'; | ||
| require_once __DIR__ . '/../../stubs/runtime/Enum/BackedEnum.php'; | ||
| require_once __DIR__ . '/../../stubs/runtime/Enum/ReflectionEnum.php'; | ||
| require_once __DIR__ . '/../../stubs/runtime/Enum/ReflectionEnumUnitCase.php'; | ||
| require_once __DIR__ . '/../../stubs/runtime/Enum/ReflectionEnumBackedCase.php'; | ||
| } | ||
| } else { | ||
| ContainerFactory::postInitializeContainer(self::$containers[$cacheKey]); | ||
| } | ||
|
|
||
| return self::$containers[$cacheKey]; | ||
| } | ||
|
|
||
| /** | ||
| * @return string[] | ||
| */ | ||
| public static function getAdditionalConfigFiles(): array | ||
| { | ||
| return []; | ||
| } | ||
|
|
||
| public static function getFileHelper(): FileHelper | ||
| { | ||
| return self::getContainer()->getByType(FileHelper::class); | ||
| } | ||
|
|
||
| } |
Check warning
Code scanning / zizmor
credential persistence through GitHub Actions artifacts Warning