|
9 | 9 | # Author : Sergey Dryabzhinsky #
|
10 | 10 | # Company : Code24 BV, The Netherlands #
|
11 | 11 | # Company : Rusoft Ltd, Russia #
|
12 |
| -# Date : July 1, 2015 # |
13 |
| -# version : 1.0.4 # |
| 12 | +# Date : July 2, 2015 # |
| 13 | +# version : 1.0.5 # |
14 | 14 | # License : Creative Commons CC-BY license #
|
15 | 15 | # Website : http://www.php-benchmark-script.com #
|
16 | 16 | # #
|
17 | 17 | ##########################################################################
|
18 | 18 | */
|
19 | 19 |
|
20 |
| -$scriptVersion = '1.0.4'; |
| 20 | +$scriptVersion = '1.0.5'; |
21 | 21 |
|
22 | 22 | $stringTest = " the quick <b>brown</b> fox jumps <i>over</i> the lazy dog and eat <span>lorem ipsum</span> Valar morghulis \n\rабыр\nвалар дохаÑÑ€Ð¸Ñ ";
|
23 | 23 |
|
|
27 | 27 | set_time_limit(0);
|
28 | 28 | ini_set('memory_limit', '2048M');
|
29 | 29 |
|
| 30 | +$line = str_pad("-",78,"-"); |
| 31 | +$padHeader = 76; |
| 32 | +$padInfo = 20; |
| 33 | +$padLabel = 62; |
| 34 | + |
30 | 35 | function get_microtime()
|
31 | 36 | {
|
32 | 37 | $time = microtime(true);
|
@@ -57,7 +62,16 @@ function test_Math($count = 1400000) {
|
57 | 62 | return number_format(get_microtime() - $time_start, 3);
|
58 | 63 | }
|
59 | 64 |
|
60 |
| - function test_String_Simple($count = 1300000) { |
| 65 | + function test_String_Concat($count = 14000000) { |
| 66 | + $time_start = get_microtime(); |
| 67 | + $s = ''; |
| 68 | + for($i = 0; $i < $count; ++$i) { |
| 69 | + $s .= "- Valar moghulis\n"; |
| 70 | + } |
| 71 | + return number_format(get_microtime() - $time_start, 3); |
| 72 | + } |
| 73 | + |
| 74 | + function test_String_Simple_Functions($count = 1300000) { |
61 | 75 | global $stringTest;
|
62 | 76 | $time_start = get_microtime();
|
63 | 77 | $stringFunctions = array("strtoupper", "strtolower", "strrev", "strlen", "str_rot13", "ord", "trim");
|
@@ -233,24 +247,25 @@ function test_Ternary($count = 90000000) {
|
233 | 247 |
|
234 | 248 | $total = 0;
|
235 | 249 | $functions = get_defined_functions();
|
236 |
| - $line = str_pad("-",38,"-"); |
237 |
| - echo "<pre>\n$line\n|".str_pad("PHP BENCHMARK SCRIPT",36," ",STR_PAD_BOTH) |
238 |
| - ."|\n$line\nStart : ".date("Y-m-d H:i:s") |
239 |
| - ."\nServer : ".php_uname() |
240 |
| - ."\nPHP version : ".PHP_VERSION |
241 |
| - ."\nBenchmark version : ".$scriptVersion |
242 |
| - ."\nPlatform : ".PHP_OS |
243 |
| - . "\n$line\n"; |
| 250 | + echo "<pre>\n$line\n|" |
| 251 | + .str_pad("PHP BENCHMARK SCRIPT", $padHeader," ",STR_PAD_BOTH) |
| 252 | + ."|\n$line\n" |
| 253 | + .str_pad("Start:", $padInfo) . " : ". date("Y-m-d H:i:s") . "\n" |
| 254 | + .str_pad("Server:", $padInfo) . " : ".php_uname() . "\n" |
| 255 | + .str_pad("PHP version:", $padInfo) . " : " .PHP_VERSION . "\n" |
| 256 | + .str_pad("Benchmark version:", $padInfo) . " : ".$scriptVersion . "\n" |
| 257 | + .str_pad("Platform:", $padInfo) . " : " .PHP_OS . "\n" |
| 258 | + ."$line\n"; |
244 | 259 | foreach ($functions['user'] as $user) {
|
245 | 260 | if (preg_match('/^test_/', $user)) {
|
246 | 261 | $result = $user();
|
247 | 262 | $total += $result;
|
248 |
| - echo str_pad($user, 25) . " : " . $result ." sec.\n"; |
| 263 | + echo str_pad($user, $padLabel) . " : " . $result ." sec.\n"; |
249 | 264 | }
|
250 | 265 | }
|
251 |
| - echo str_pad("-", 38, "-") . "\n" |
252 |
| - . str_pad("Total time:", 25) . " : " . $total ." sec.\n" |
253 |
| - . str_pad("Current memory usage:", 25) . " : " . convert(memory_get_usage()) .".\n" |
254 |
| - . (function_exists('memory_get_peak_usage') ? str_pad("Peak memory usage:", 25) . " : " . convert(memory_get_peak_usage()) .".\n" : '') |
| 266 | + echo $line . "\n" |
| 267 | + . str_pad("Total time:", $padLabel) . " : " . $total ." sec.\n" |
| 268 | + . str_pad("Current memory usage:", $padLabel) . " : " . convert(memory_get_usage()) .".\n" |
| 269 | + . (function_exists('memory_get_peak_usage') ? str_pad("Peak memory usage:", $padLabel) . " : " . convert(memory_get_peak_usage()) .".\n" : '') |
255 | 270 | . "</pre>\n";
|
256 | 271 | ?>
|
0 commit comments