Skip to content

Commit 943242d

Browse files
Добавил тест копирования строк
1 parent 7ad0304 commit 943242d

File tree

2 files changed

+39
-20
lines changed

2 files changed

+39
-20
lines changed

README.md

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,19 @@
44

55
## ChangeLog
66

7-
@ 2015-07-01, v1.0.4
7+
@ 2015-07-02, v1.0.5
8+
9+
* Добавлени тест простейшего копирования строк
10+
11+
@ 2015-07-02, v1.0.4
812

913
* Добавлено увеличение лимита по памяти и времени выполнения
1014

11-
@ 2015-07-01, v1.0.3
15+
@ 2015-07-02, v1.0.3
1216

1317
* Исправлено определение доступных функций, сделан пропуск тестов для них
1418

15-
@ 2015-07-01, v1.0.2
19+
@ 2015-07-02, v1.0.2
1620

1721
* Добавлено еще больше функций, теперь трубается наличие mbstring и json модулей
1822
* Потребление памяти увеличено из-за тестирования массивов - нужно более 1Гб

bench.php

Lines changed: 32 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -9,15 +9,15 @@
99
# Author : Sergey Dryabzhinsky #
1010
# Company : Code24 BV, The Netherlands #
1111
# Company : Rusoft Ltd, Russia #
12-
# Date : July 1, 2015 #
13-
# version : 1.0.4 #
12+
# Date : July 2, 2015 #
13+
# version : 1.0.5 #
1414
# License : Creative Commons CC-BY license #
1515
# Website : http://www.php-benchmark-script.com #
1616
# #
1717
##########################################################################
1818
*/
1919

20-
$scriptVersion = '1.0.4';
20+
$scriptVersion = '1.0.5';
2121

2222
$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валар дохаэрис ";
2323

@@ -27,6 +27,11 @@
2727
set_time_limit(0);
2828
ini_set('memory_limit', '2048M');
2929

30+
$line = str_pad("-",78,"-");
31+
$padHeader = 76;
32+
$padInfo = 20;
33+
$padLabel = 62;
34+
3035
function get_microtime()
3136
{
3237
$time = microtime(true);
@@ -57,7 +62,16 @@ function test_Math($count = 1400000) {
5762
return number_format(get_microtime() - $time_start, 3);
5863
}
5964

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) {
6175
global $stringTest;
6276
$time_start = get_microtime();
6377
$stringFunctions = array("strtoupper", "strtolower", "strrev", "strlen", "str_rot13", "ord", "trim");
@@ -233,24 +247,25 @@ function test_Ternary($count = 90000000) {
233247

234248
$total = 0;
235249
$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";
244259
foreach ($functions['user'] as $user) {
245260
if (preg_match('/^test_/', $user)) {
246261
$result = $user();
247262
$total += $result;
248-
echo str_pad($user, 25) . " : " . $result ." sec.\n";
263+
echo str_pad($user, $padLabel) . " : " . $result ." sec.\n";
249264
}
250265
}
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" : '')
255270
. "</pre>\n";
256271
?>

0 commit comments

Comments
 (0)