Skip to content

Commit fad27dd

Browse files
First fixes for 1.0.40:
- buffered nginx output - add 4096+ empty text line - disable opcache if possible - check for cli opcache - break if enabled
1 parent 262a56e commit fad27dd

File tree

3 files changed

+43
-8
lines changed

3 files changed

+43
-8
lines changed

.htaccess

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,12 @@
11
php_flag display_errors off
22
php_flag implicit_flush 1
33
php_flag xdebug.show_exception_trace 0
4+
php_flag opcache.enable 0
5+
php_flag xdebug.default_enable 0
46

57
php_value output_bufering 0
8+
php_value max_execution_time 600
69
php_value error_log /dev/null
10+
php_value memory_limit 256M
711
php_value mbstring.internal_encoding UTF-8
812
php_value mbstring.func_overload 0
9-
php_value memory_limit 256M

.user.ini

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
[PHP]
2+
display_errors = off
3+
implicit_flush = 1
4+
xdebug.show_exception_trace = 0
5+
opcache.enable = 0
6+
xdebug.default_enable = 0
7+
8+
output_bufering = 0
9+
max_execution_time = 600
10+
error_log = /dev/null
11+
memory_limit = 256M
12+
mbstring.internal_encoding = UTF-8
13+
mbstring.func_overload = 0

bench.php

Lines changed: 26 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -32,13 +32,18 @@ function print_pre($msg) {
3232
flush();
3333
}
3434

35-
$scriptVersion = '1.0.39';
35+
$scriptVersion = '1.0.40-dev';
36+
37+
// Special striing to flush buffers, nginx for example
38+
$flushStr = '<span style="display:none">'.str_repeat(" ", 4096).'</span>';
3639

3740
if (php_sapi_name() != 'cli') {
3841
// Hello, nginx!
3942
header('X-Accel-Buffering: no', true);
4043
header('Content-Type: text/html; charset=utf-8', true);
4144
flush();
45+
} else {
46+
$flushStr = '';
4247
}
4348

4449
$tz = ini_get('date.timezone');
@@ -50,19 +55,32 @@ function print_pre($msg) {
5055
ini_set('output_buffering', 0);
5156
ob_implicit_flush(1);
5257

53-
error_reporting(E_ERROR | E_WARNING | E_PARSE);
5458
// Disable explicit error reporting
55-
$xdebug = ini_get('xdebug.default_enable');
56-
ini_set('xdebug.show_exception_trace', 0);
59+
error_reporting(E_ERROR | E_WARNING | E_PARSE);
5760

61+
// Check XDebug
62+
$xdebug = ini_get('xdebug.default_enable');
5863
if ($xdebug) {
5964
print_pre('<<< ERROR >>> You need to disable Xdebug extension! It greatly slow things down!'.PHP_EOL);
6065
exit(1);
6166
}
67+
ini_set('xdebug.show_exception_trace', 0);
68+
69+
// Check OpCache
70+
$opcache = ini_get('opcache.enable');
71+
if ($opcache) {
72+
print_pre('<<< ERROR >>> You need to disable OpCache extension! It may affect results greatly! Make it via .htaccess, VHost or fpm config'.PHP_EOL);
73+
exit(1);
74+
}
75+
$opcache = ini_get('opcache.enable_cli');
76+
if ($opcache) {
77+
print_pre('<<< ERROR >>> You need to disable Cli OpCache extension! It may affect results greatly! Run php with param: -dopcache.enable_cli=0'.PHP_EOL);
78+
exit(1);
79+
}
6280

6381
$mbover = ini_get('mbstring.func_overload');
6482
if ($mbover == 2) {
65-
print_pre('<<< ERROR >>> You need to disable mbstring string functions overloading! It greatly slow things down!'.PHP_EOL);
83+
print_pre('<<< ERROR >>> You need to disable mbstring string functions overloading! It greatly slow things down! And messes with results.'.PHP_EOL);
6684
exit(1);
6785
}
6886

@@ -1512,14 +1530,14 @@ function test_20_Type_Conversion()
15121530
. str_pad("pcre", $padInfo, ' ', STR_PAD_LEFT) . " : $has_pcre\n"
15131531
. str_pad("Max execution time", $padInfo) . " : " . $maxTime . " sec\n"
15141532
. str_pad("Crypt hash algo", $padInfo) . " : " . $cryptAlgoName . "\n"
1515-
. "$line\n";
1533+
. "$line\n" . $flushStr;
15161534
flush();
15171535

15181536
if (!$showOnlySystemInfo) {
15191537

15201538
echo str_pad('TEST NAME', $padLabel) . " :"
15211539
. str_pad('SECONDS', 9 + 4, ' ', STR_PAD_LEFT) . " |" . str_pad('OP/SEC', 9 + 4, ' ', STR_PAD_LEFT) . " |" . str_pad('OP/SEC/MHz', 9 + 7, ' ', STR_PAD_LEFT) . " |" . str_pad('MEMORY', 10, ' ', STR_PAD_LEFT) . "\n"
1522-
. "$line\n";
1540+
. "$line\n" . $flushStr;
15231541
flush();
15241542

15251543
foreach ($functions['user'] as $user) {
@@ -1534,6 +1552,7 @@ function test_20_Type_Conversion()
15341552
list($resultSec, $resultSecFmt, $resultOps, $resultOpMhz, $memory) = $user();
15351553
$total += $resultSec;
15361554
echo str_pad($resultSecFmt, 9, ' ', STR_PAD_LEFT) . " sec |" . str_pad($resultOps, 9, ' ', STR_PAD_LEFT) . "Op/s |" . str_pad($resultOpMhz, 9, ' ', STR_PAD_LEFT) . "Ops/MHz |" . str_pad($memory, 10, ' ', STR_PAD_LEFT) . "\n";
1555+
echo $flushStr;
15371556
flush();
15381557
}
15391558
}

0 commit comments

Comments
 (0)