Skip to content

Commit 3b2773a

Browse files
committed
Upload callgrind profile to GA
1 parent b2d244a commit 3b2773a

File tree

3 files changed

+22
-4
lines changed

3 files changed

+22
-4
lines changed

.github/workflows/push.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -288,3 +288,8 @@ jobs:
288288
${{ github.sha }} \
289289
$(git merge-base ${{ github.event.pull_request.base.sha }} ${{ github.sha }}) \
290290
> $GITHUB_STEP_SUMMARY
291+
- uses: actions/upload-artifact@v3
292+
with:
293+
name: profiles
294+
path: ${{ github.workspace }}/benchmarking/profiles
295+
retention-days: 30

benchmark/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
1+
/profiles
12
/repos

benchmark/benchmark.php

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,11 @@
1212
function main() {
1313
global $storeResult;
1414

15+
$profilesDir = __DIR__ . '/profiles';
16+
if (!is_dir($profilesDir)) {
17+
mkdir($profilesDir, 0755, true);
18+
}
19+
1520
$data = [];
1621
if (false !== $branch = getenv('GITHUB_REF_NAME')) {
1722
$data['branch'] = $branch;
@@ -50,15 +55,15 @@ function getPhpSrcCommitHash(): string {
5055
}
5156

5257
function runBench(bool $jit): array {
53-
return runValgrindPhpCgiCommand([dirname(__DIR__) . '/Zend/bench.php'], jit: $jit);
58+
return runValgrindPhpCgiCommand('bench', [dirname(__DIR__) . '/Zend/bench.php'], jit: $jit);
5459
}
5560

5661
function runSymfonyDemo(bool $jit): array {
5762
$dir = __DIR__ . '/repos/symfony-demo-2.2.3';
5863
cloneRepo($dir, 'https://github.com/php/benchmarking-symfony-demo-2.2.3.git');
5964
runPhpCommand([$dir . '/bin/console', 'cache:clear']);
6065
runPhpCommand([$dir . '/bin/console', 'cache:warmup']);
61-
return runValgrindPhpCgiCommand([$dir . '/public/index.php'], cwd: $dir, jit: $jit, warmup: 50, repeat: 50);
66+
return runValgrindPhpCgiCommand('symfony-demo', [$dir . '/public/index.php'], cwd: $dir, jit: $jit, warmup: 50, repeat: 50);
6267
}
6368

6469
function runWordpress(bool $jit): array {
@@ -81,26 +86,33 @@ function runWordpress(bool $jit): array {
8186

8287
// Warmup
8388
runPhpCommand([$dir . '/index.php'], $dir);
84-
return runValgrindPhpCgiCommand([$dir . '/index.php'], cwd: $dir, jit: $jit, warmup: 50, repeat: 50);
89+
return runValgrindPhpCgiCommand('wordpress', [$dir . '/index.php'], cwd: $dir, jit: $jit, warmup: 50, repeat: 50);
8590
}
8691

8792
function runPhpCommand(array $args, ?string $cwd = null): ProcessResult {
8893
return runCommand([PHP_BINARY, ...$args], $cwd);
8994
}
9095

9196
function runValgrindPhpCgiCommand(
97+
string $name,
9298
array $args,
9399
?string $cwd = null,
94100
bool $jit = false,
95101
int $warmup = 0,
96102
int $repeat = 1,
97103
): array {
98104
global $phpCgi;
105+
106+
$profileOut = __DIR__ . "/profiles/callgrind.out.$name";
107+
if ($jit) {
108+
$profileOut .= '.jit';
109+
}
110+
99111
$process = runCommand([
100112
'valgrind',
101113
'--tool=callgrind',
102114
'--dump-instr=yes',
103-
'--callgrind-out-file=/dev/null',
115+
"--callgrind-out-file=$profileOut",
104116
'--',
105117
$phpCgi,
106118
'-T' . ($warmup ? $warmup . ',' : '') . $repeat,

0 commit comments

Comments
 (0)