1212function 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
5257function 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
5661function 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
6469function 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
8792function runPhpCommand (array $ args , ?string $ cwd = null ): ProcessResult {
8893 return runCommand ([PHP_BINARY , ...$ args ], $ cwd );
8994}
9095
9196function 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