Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 605929b

Browse files
Версия 1.0.12
- заголовок для столбцов - правильный перевод в систему SI - считаем op/sec/mhz
1 parent 418225e commit 605929b

File tree

2 files changed

+36
-8
lines changed

2 files changed

+36
-8
lines changed

‎README.md‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,12 @@
44

55
## ChangeLog
66

7+
@ 2017年04月21日, v1.0.12
8+
9+
* Правильная конвертация значений в единицы SI.
10+
* Считаем операции в секунду на МГц.
11+
* Обновил вывод - добавил заголовок столбцам
12+
713
@ 2017年04月20日, v1.0.11
814

915
* Нагружаем процессор, чтобы определить MHz только если разница между

‎bench.php‎

Lines changed: 30 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,14 @@
1010
# Author : Sergey Dryabzhinsky #
1111
# Company : Rusoft Ltd, Russia #
1212
# Date : Apr 20, 2017 #
13-
# version : 1.0.11 #
13+
# version : 1.0.12 #
1414
# License : Creative Commons CC-BY license #
1515
# Website : https://git.rusoft.ru/open-source/php-simple-benchmark-script #
1616
# #
1717
################################################################################
1818
*/
1919

20-
$scriptVersion = '1.0.11';
20+
$scriptVersion = '1.0.12';
2121

2222
$stringTest = " the quick <b>brown</b> fox jumps <i>over</i> the lazy dog and eat <span>lorem ipsum</span> Valar morghulis <br/>\n\rабыр\nвалар дохаэрис ";
2323
$regexPattern = '/[\s,]+/';
@@ -28,7 +28,7 @@
2828
$line = str_pad("-",78,"-");
2929
$padHeader = 76;
3030
$padInfo = 18;
31-
$padLabel = 32;
31+
$padLabel = 31;
3232

3333
$emptyResult = array(0, '-.---', '-.--', '-.--');
3434

@@ -50,14 +50,32 @@ function convert($size)
5050

5151
function prefix_si($size)
5252
{
53-
$unit=array('','k','M','G','T','P','E');
53+
$unit=array('','k','M','G','T','P','E', -3 => 'm', -6 => 'u');
5454
$i=floor(log($size,1000));
55+
if ($i < 0) {
56+
if ($i <= -6) {
57+
$i = -6;
58+
elseif ($i <= -3) {
59+
$i = -3;
60+
} else {
61+
$i=0;
62+
}
63+
}
5564
return $unit[$i];
5665
}
5766

5867
function convert_si($size)
5968
{
6069
$i=floor(log($size,1000));
70+
if ($i < 0) {
71+
if ($i <= -6) {
72+
$i = -6;
73+
elseif ($i <= -3) {
74+
$i = -3;
75+
} else {
76+
$i=0;
77+
}
78+
}
6179
return @round($size/pow(1000, $i),2);
6280
}
6381

@@ -157,7 +175,7 @@ function format_result_test($diffSeconds, $opCount)
157175

158176
$opmhz = 0;
159177
if (!empty($cpuInfo['mhz'])) {
160-
$opmhz = $opCount / $cpuInfo['mhz'];
178+
$opmhz = $ops / $cpuInfo['mhz'];
161179
}
162180
$opmhz_v = convert_si($opmhz);
163181
$opmhz_u = prefix_si($opmhz);
@@ -167,7 +185,7 @@ function format_result_test($diffSeconds, $opCount)
167185
number_format($opmhz_v, 2, '.', '') . ''.$opmhz_u,
168186
);
169187
} else {
170-
return array(0, '0.000', 'x.xx ', 'x.xx');
188+
return array(0, '0.000', 'x.xx ', 'x.xx');
171189
}
172190
}
173191

@@ -506,15 +524,19 @@ function test_17_2_Loop_Undefined_Access($count = 20000000)
506524
.str_pad("PHP version:", $padInfo) . " : " .PHP_VERSION . "\n"
507525
.str_pad("Benchmark version:", $padInfo) . " : ".$scriptVersion . "\n"
508526
.str_pad("Platform:", $padInfo) . " : " .PHP_OS . "\n"
509-
."$line\n";
527+
."$line\n"
528+
.str_pad('TEST NAME', $padLabel) . " :"
529+
.str_pad('SECONDS', 8+4, '', STR_PAD_LEFT)." |".str_pad('OP/SEC', 9+4, '', STR_PAD_LEFT)." |".str_pad('OP/SEC/MHz', 9+7, '', STR_PAD_LEFT)."\n"
530+
."$line\n"
531+
;
510532

511533
foreach ($functions['user'] as $user) {
512534
if (preg_match('/^test_/', $user)) {
513535
$testName = str_replace('test_','',$user);
514536
echo str_pad($testName, $padLabel) . " :";
515537
list($resultSec, $resultSecFmt, $resultOps, $resultOpMhz) = $user();
516538
$total += $resultSec;
517-
echo str_pad($resultSecFmt, 8, '', STR_PAD_LEFT)." sec |".str_pad($resultOps, 9, '', STR_PAD_LEFT)."Op/s |".str_pad($resultOpMhz, 9, '', STR_PAD_LEFT)."Op/Mhz"."\n";
539+
echo str_pad($resultSecFmt, 8, '', STR_PAD_LEFT)." sec |".str_pad($resultOps, 9, '', STR_PAD_LEFT)."Op/s |".str_pad($resultOpMhz, 9, '', STR_PAD_LEFT)."Ops/MHz"."\n";
518540
}
519541
}
520542

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /