@@ -13,9 +13,12 @@ function main() {
13
13
global $ storeResult ;
14
14
15
15
$ data = [];
16
- $ data ['Zend/bench.php ' ] = runBench ();
17
- $ data ['Symfony Demo 2.2.3 ' ] = runSymfonyDemo ();
18
- $ data ['Wordpress 6.2 ' ] = runWordpress ();
16
+ $ data ['Zend/bench.php ' ] = runBench (false );
17
+ $ data ['Zend/bench.php JIT ' ] = runBench (true );
18
+ $ data ['Symfony Demo 2.2.3 ' ] = runSymfonyDemo (false );
19
+ $ data ['Symfony Demo 2.2.3 JIT ' ] = runSymfonyDemo (true );
20
+ $ data ['Wordpress 6.2 ' ] = runWordpress (false );
21
+ $ data ['Wordpress 6.2 JIT ' ] = runWordpress (true );
19
22
$ result = json_encode ($ data , JSON_PRETTY_PRINT ) . "\n" ;
20
23
21
24
fwrite (STDOUT , $ result );
@@ -43,21 +46,19 @@ function getPhpSrcCommitHash(): string {
43
46
return $ result ->stdout ;
44
47
}
45
48
46
- function runBench (): array {
47
- $ process = runValgrindPhpCgiCommand ([dirname (__DIR__ ) . '/Zend/bench.php ' ]);
48
- return ['instructions ' => extractInstructionsFromValgrindOutput ($ process ->stderr )];
49
+ function runBench (bool $ jit ): array {
50
+ return runValgrindPhpCgiCommand ([dirname (__DIR__ ) . '/Zend/bench.php ' ], jit: $ jit );
49
51
}
50
52
51
- function runSymfonyDemo (): array {
53
+ function runSymfonyDemo (bool $ jit ): array {
52
54
$ dir = __DIR__ . '/repos/symfony-demo-2.2.3 ' ;
53
55
cloneRepo ($ dir , 'https://github.com/iluuu1994/symfony-demo-2.2.3.git ' );
54
56
runPhpCommand ([$ dir . '/bin/console ' , 'cache:clear ' ]);
55
57
runPhpCommand ([$ dir . '/bin/console ' , 'cache:warmup ' ]);
56
- $ process = runValgrindPhpCgiCommand (['-T1,1 ' , $ dir . '/public/index.php ' ]);
57
- return ['instructions ' => extractInstructionsFromValgrindOutput ($ process ->stderr )];
58
+ return runValgrindPhpCgiCommand ([$ dir . '/public/index.php ' ], cwd: $ dir , jit: $ jit , warmup: 10 );
58
59
}
59
60
60
- function runWordpress (): array {
61
+ function runWordpress (bool $ jit ): array {
61
62
$ dir = __DIR__ . '/repos/wordpress-6.2 ' ;
62
63
cloneRepo ($ dir , 'https://github.com/iluuu1994/wordpress-6.2.git ' );
63
64
@@ -77,26 +78,35 @@ function runWordpress(): array {
77
78
78
79
// Warmup
79
80
runPhpCommand ([$ dir . '/index.php ' ], $ dir );
80
- $ process = runValgrindPhpCgiCommand (['-T1,1 ' , $ dir . '/index.php ' ], $ dir );
81
- return ['instructions ' => extractInstructionsFromValgrindOutput ($ process ->stderr )];
81
+ return runValgrindPhpCgiCommand ([$ dir . '/index.php ' ], cwd: $ dir , jit: $ jit , warmup: 10 );
82
82
}
83
83
84
84
function runPhpCommand (array $ args , ?string $ cwd = null ): ProcessResult {
85
85
return runCommand ([PHP_BINARY , ...$ args ], $ cwd );
86
86
}
87
87
88
- function runValgrindPhpCgiCommand (array $ args , ?string $ cwd = null ): ProcessResult {
88
+ function runValgrindPhpCgiCommand (
89
+ array $ args ,
90
+ ?string $ cwd = null ,
91
+ bool $ jit = false ,
92
+ int $ warmup = 0 ,
93
+ ): array {
89
94
global $ phpCgi ;
90
- return runCommand ([
95
+ $ process = runCommand ([
91
96
'valgrind ' ,
92
97
'--tool=callgrind ' ,
93
98
'--dump-instr=yes ' ,
94
99
'--callgrind-out-file=/dev/null ' ,
95
100
'-- ' ,
96
101
$ phpCgi ,
102
+ '-T ' . ($ warmup ? $ warmup . ', ' : '' ) . '1 ' ,
97
103
'-d max_execution_time=0 ' ,
104
+ '-d opcache.enable=1 ' ,
105
+ '-d opcache.jit_buffer_size= ' . ($ jit ? '128M ' : '0 ' ),
98
106
...$ args ,
99
107
]);
108
+ $ instructions = extractInstructionsFromValgrindOutput ($ process ->stderr );
109
+ return ['instructions ' => $ instructions ];
100
110
}
101
111
102
112
function extractInstructionsFromValgrindOutput (string $ output ): ?string {
0 commit comments