12
12
function main () {
13
13
global $ storeResult ;
14
14
15
+ $ profilesDir = __DIR__ . '/profiles ' ;
16
+ if (!is_dir ($ profilesDir )) {
17
+ mkdir ($ profilesDir , 0755 , true );
18
+ }
19
+
15
20
$ data = [];
16
21
if (false !== $ branch = getenv ('GITHUB_REF_NAME ' )) {
17
22
$ data ['branch ' ] = $ branch ;
@@ -50,15 +55,15 @@ function getPhpSrcCommitHash(): string {
50
55
}
51
56
52
57
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 );
54
59
}
55
60
56
61
function runSymfonyDemo (bool $ jit ): array {
57
62
$ dir = __DIR__ . '/repos/symfony-demo-2.2.3 ' ;
58
63
cloneRepo ($ dir , 'https://github.com/php/benchmarking-symfony-demo-2.2.3.git ' );
59
64
runPhpCommand ([$ dir . '/bin/console ' , 'cache:clear ' ]);
60
65
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 );
62
67
}
63
68
64
69
function runWordpress (bool $ jit ): array {
@@ -81,26 +86,33 @@ function runWordpress(bool $jit): array {
81
86
82
87
// Warmup
83
88
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 );
85
90
}
86
91
87
92
function runPhpCommand (array $ args , ?string $ cwd = null ): ProcessResult {
88
93
return runCommand ([PHP_BINARY , ...$ args ], $ cwd );
89
94
}
90
95
91
96
function runValgrindPhpCgiCommand (
97
+ string $ name ,
92
98
array $ args ,
93
99
?string $ cwd = null ,
94
100
bool $ jit = false ,
95
101
int $ warmup = 0 ,
96
102
int $ repeat = 1 ,
97
103
): array {
98
104
global $ phpCgi ;
105
+
106
+ $ profileOut = __DIR__ . "/profiles/callgrind.out. $ name " ;
107
+ if ($ jit ) {
108
+ $ profileOut .= '.jit ' ;
109
+ }
110
+
99
111
$ process = runCommand ([
100
112
'valgrind ' ,
101
113
'--tool=callgrind ' ,
102
114
'--dump-instr=yes ' ,
103
- ' --callgrind-out-file=/dev/null ' ,
115
+ " --callgrind-out-file= $ profileOut " ,
104
116
'-- ' ,
105
117
$ phpCgi ,
106
118
'-T ' . ($ warmup ? $ warmup . ', ' : '' ) . $ repeat ,
0 commit comments