Skip to content

Commit 418225e

Browse files
Версия 1.0.11
- нагружаем CPU только если вычисленные значения сильно расходятся
1 parent 53ecaf2 commit 418225e

File tree

2 files changed

+19
-11
lines changed

2 files changed

+19
-11
lines changed

README.md

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

55
## ChangeLog
66

7+
@ 2017-04-20, v1.0.11
8+
9+
* Нагружаем процессор, чтобы определить MHz только если разница между
10+
значениями 'cpu MHz' и 'bogomips/2' большая.
11+
712
@ 2017-04-20, v1.0.10
813

914
* Тесты массивов теперь всегда включены, они больше не съедают много памяти

bench.php

Lines changed: 14 additions & 11 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.10 #
13+
# version : 1.0.11 #
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.10';
20+
$scriptVersion = '1.0.11';
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,]+/';
@@ -64,7 +64,7 @@ function convert_si($size)
6464
/**
6565
* Read /proc/cpuinfo, fetch some data
6666
*/
67-
function getCpuInfo()
67+
function getCpuInfo($fireUpCpu=false)
6868
{
6969
$cpu = array(
7070
'model' => '',
@@ -81,9 +81,11 @@ function getCpuInfo()
8181
// Code from https://github.com/jrgp/linfo/blob/master/src/Linfo/OS/Linux.php
8282
// Adopted
8383

84-
// Fire up CPU
85-
$i = 100000000;
86-
while ($i--);
84+
if ($fireUpCpu) {
85+
// Fire up CPU
86+
$i = 100000000;
87+
while ($i--);
88+
}
8789

8890
$cpuData = explode("\n", file_get_contents('/proc/cpuinfo'));
8991

@@ -129,16 +131,17 @@ function getCpuInfo()
129131
}
130132
}
131133

132-
// CPU throttling?
133-
if (abs($cpu['mips'] - $cpu['mhz']) > 400) {
134-
print('<<< WARNING >>> CPU is in powersaving mode? Set CPU governor to "performance"!' . PHP_EOL);
135-
}
136-
137134
return $cpu;
138135
}
139136

140137

141138
$cpuInfo = getCpuInfo();
139+
// CPU throttling?
140+
if (abs($cpu['mips'] - $cpu['mhz']) > 400) {
141+
print("<pre>\n<<< WARNING >>>\nCPU is in powersaving mode? Set CPU governor to 'performance'!\nFire up CPU and recalculate MHz!\n</pre>" . PHP_EOL);
142+
$cpuInfo = getCpuInfo(true);
143+
}
144+
142145

143146

144147
/**

0 commit comments

Comments
 (0)