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 f43eca9

Browse files
Merge pull request 'Новые форматы вывод данных' (#4) from sergeyd-issues-20-21-output-machine-json-formats into master
Reviewed-on: https://gitea.rusoft.ru/open-source/php-simple-benchmark-script/pulls/4
2 parents 2b5bf9d + b90dce1 commit f43eca9

File tree

4 files changed

+619
-224
lines changed

4 files changed

+619
-224
lines changed

‎CHANGELOG.md‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
# ChangeLog
22

3+
@ 2022年05月04日, v1.0.48
4+
5+
* Переделан порядок инициализации переменных из командной строки
6+
* Добавлен вывод в машино-читаемом формате, без лишних данных, без преобразования формата чисел
7+
* Добавлен вывод в JSON-формате, без лишних данных, без преобразования формата чисел
8+
39
@ 2022年05月03日, v1.0.47
410

511
* Улучшен вывод предупреждения про xdebug

‎README.en.md‎

Lines changed: 48 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,10 +36,12 @@ You need to put these files in one directory: `bench.php`, `common.inc`, `php5.i
3636

3737
Command:
3838
```
39-
Usage: bench.php [-h|--help] [-x|--debug] [-d|--dont-recalc] [-D|--dumb-test-print] [-L|--list-tests] [-I|--system-info] [-S|--do-not-task-set] [-m|--memory-limit=130] [-t|--time-limit=600] [-T|--run-test=name1 ...]
39+
Usage: bench.php [-h|--help] [-x|--debug] [-J|--print-json] [-M|--print-machine] [-d|--dont-recalc] [-D|--dumb-test-print] [-L|--list-tests] [-I|--system-info] [-S|--do-not-task-set] [-m|--memory-limit=130] [-t|--time-limit=600] [-T|--run-test=name1 ...]
4040
4141
-h|--help - print this help and exit
4242
-x|--debug - enable debug mode, raise output level
43+
-J|--print-json - enable printing only in JSON format, useful for automated tests. disables print-machine.
44+
-M|--print-machine - enable printing only in machine parsable format, useful for automated tests. disables print-json.
4345
-d|--dont-recalc - do not recalculate test times / operations count even if memory of execution time limits are low
4446
-D|--dumb-test-print - print dumb test time, for debug purpose
4547
-L|--list-tests - output list of available tests and exit
@@ -59,6 +61,8 @@ Available variables:
5961

6062
- PHP_TIME_LIMIT=<Секунды>
6163
- PHP_DEBUG_MODE=0/1
64+
- PRINT_JSON=0/1
65+
- PRINT_MACHINE=0/1
6266
- PHP_MEMORY_LIMIT=<Мб>
6367
- DONT_RECALCULATE_LIMITS=0/1
6468
- LIST_TESTS=0/1
@@ -84,6 +88,8 @@ Available options:
8488

8589
- time_limit=Секунды
8690
- debug_mode=0/1
91+
- print_json=0/1
92+
- print_machine=0/1
8793
- memory_limit=Мб
8894
- dont_recalculate_limits=0/1
8995
- list_tests=0/1
@@ -107,6 +113,8 @@ This applies to all ARM, MIPS, etc. As well as old AMD and Intel processors like
107113

108114
## Example script output
109115

116+
### Generic format
117+
110118
```
111119
<<< WARNING >>> You need to disable Xdebug extension! It greatly slow things down! And mess with PHP internals.
112120
<<< WARNING >>> Execution time limit not droppped to '600' seconds!
@@ -197,3 +205,42 @@ Total time: : 81.337 sec | 13.73 MOp/s | 3.62 kOps/MHz |
197205
Current PHP memory usage: : 4 Mb
198206
Peak PHP memory usage: : 86.58 Mb
199207
```
208+
209+
### JSON-format
210+
211+
Command: `php74 -derror_log= -dxdebug.mode=off bench.php -T 01_math -T 33_phpinfo_generate -J`
212+
```
213+
{
214+
"php_benchmark_script": "1.0.48-dev",
215+
"start": "2022年05月03日 22:11:19",
216+
"server": "Linux/5.4.0-104-lowlatency x86_64",
217+
"system": "Ubuntu 18.04.6 LTS",
218+
"php_version": "7.4.29-SergeyD/6.1",
219+
"results": {
220+
"columns": [ "test_name", "seconds", "op\/sec", "op\/sec\/MHz", "memory" ],
221+
"rows": [
222+
[ "01_math", 3.4119508266449, 586174.91916397, 162.82636643444, 4194304 ],
223+
[ "33_phpinfo_generate", 3.6402199268341, 2747.0867697538, 0.76307965826494, 4194304 ],
224+
null
225+
]
226+
},
227+
"total": { "seconds": 7.052170753479, "op\/sec":285018.62338039, "op\/sec\/MHz":79.171839827885 },
228+
"messages_count": 0,
229+
"end":true
230+
}
231+
```
232+
233+
### Machine-parsable format
234+
235+
Command: `php74 -derror_log= -dxdebug.mode=off bench.php -T 01_math -T 33_phpinfo_generate -M`
236+
```
237+
PHP_BENCHMARK_SCRIPT: 1.0.48-dev
238+
START: 2022年05月03日 22:11:52
239+
SERVER: Linux/5.4.0-104-lowlatency x86_64
240+
SYSTEM: Ubuntu 18.04.6 LTS
241+
PHP_VERSION: 7.4.29-SergeyD/6.1
242+
TEST_NAME: SECONDS, OP/SEC, OP/SEC/MHz, MEMORY
243+
01_math: 3.3808300495148, 591570.70030392, 164.32519452887, 4194304
244+
33_phpinfo_generate: 3.6759581565857, 2720.3791702809, 0.75566088063359, 4194304
245+
TOTAL: 7.0567882061005, 284832.12777484, 79.120035493011
246+
```

‎README.md‎

Lines changed: 48 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,10 +36,12 @@
3636

3737
Команда:
3838
```
39-
Usage: bench.php [-h|--help] [-x|--debug] [-d|--dont-recalc] [-D|--dumb-test-print] [-L|--list-tests] [-I|--system-info] [-S|--do-not-task-set] [-m|--memory-limit=130] [-t|--time-limit=600] [-T|--run-test=name1 ...]
39+
Usage: bench.php [-h|--help] [-x|--debug] [-J|--print-json] [-M|--print-machine] [-d|--dont-recalc] [-D|--dumb-test-print] [-L|--list-tests] [-I|--system-info] [-S|--do-not-task-set] [-m|--memory-limit=130] [-t|--time-limit=600] [-T|--run-test=name1 ...]
4040
4141
-h|--help - print this help and exit
4242
-x|--debug - enable debug mode, raise output level
43+
-J|--print-json - enable printing only in JSON format, useful for automated tests. disables print-machine.
44+
-M|--print-machine - enable printing only in machine parsable format, useful for automated tests. disables print-json.
4345
-d|--dont-recalc - do not recalculate test times / operations count even if memory of execution time limits are low
4446
-D|--dumb-test-print - print dumb test time, for debug purpose
4547
-L|--list-tests - output list of available tests and exit
@@ -59,6 +61,8 @@ env PHP_MEMORY_LIMIT=64 PHP_TIME_LIMIT=30 php bench.php
5961

6062
- PHP_TIME_LIMIT=<Секунды>
6163
- PHP_DEBUG_MODE=0/1
64+
- PRINT_JSON=0/1
65+
- PRINT_MACHINE=0/1
6266
- PHP_MEMORY_LIMIT=<Мб>
6367
- DONT_RECALCULATE_LIMITS=0/1
6468
- LIST_TESTS=0/1
@@ -84,6 +88,8 @@ env PHP_MEMORY_LIMIT=64 PHP_TIME_LIMIT=30 php bench.php
8488

8589
- time_limit=Секунды
8690
- debug_mode=0/1
91+
- print_json=0/1
92+
- print_machine=0/1
8793
- memory_limit=Мб
8894
- dont_recalculate_limits=0/1
8995
- list_tests=0/1
@@ -108,6 +114,8 @@ env PHP_MEMORY_LIMIT=64 PHP_TIME_LIMIT=30 php bench.php
108114

109115
## Пример вывода скрипта
110116

117+
### Обычный режим
118+
111119
```
112120
<<< WARNING >>> You need to disable Xdebug extension! It greatly slow things down! And mess with PHP internals.
113121
<<< WARNING >>> Execution time limit not droppped to '600' seconds!
@@ -198,3 +206,42 @@ Total time: : 81.337 sec | 13.73 MOp/s | 3.62 kOps/MHz |
198206
Current PHP memory usage: : 4 Mb
199207
Peak PHP memory usage: : 86.58 Mb
200208
```
209+
210+
### JSON-формат
211+
212+
Команда: `php74 -derror_log= -dxdebug.mode=off bench.php -T 01_math -T 33_phpinfo_generate -J`
213+
```
214+
{
215+
"php_benchmark_script": "1.0.48-dev",
216+
"start": "2022年05月03日 22:11:19",
217+
"server": "Linux/5.4.0-104-lowlatency x86_64",
218+
"system": "Ubuntu 18.04.6 LTS",
219+
"php_version": "7.4.29-SergeyD/6.1",
220+
"results": {
221+
"columns": [ "test_name", "seconds", "op\/sec", "op\/sec\/MHz", "memory" ],
222+
"rows": [
223+
[ "01_math", 3.4119508266449, 586174.91916397, 162.82636643444, 4194304 ],
224+
[ "33_phpinfo_generate", 3.6402199268341, 2747.0867697538, 0.76307965826494, 4194304 ],
225+
null
226+
]
227+
},
228+
"total": { "seconds": 7.052170753479, "op\/sec":285018.62338039, "op\/sec\/MHz":79.171839827885 },
229+
"messages_count": 0,
230+
"end":true
231+
}
232+
```
233+
234+
### Машино-читаемый формат
235+
236+
Команда: `php74 -derror_log= -dxdebug.mode=off bench.php -T 01_math -T 33_phpinfo_generate -M`
237+
```
238+
PHP_BENCHMARK_SCRIPT: 1.0.48-dev
239+
START: 2022年05月03日 22:11:52
240+
SERVER: Linux/5.4.0-104-lowlatency x86_64
241+
SYSTEM: Ubuntu 18.04.6 LTS
242+
PHP_VERSION: 7.4.29-SergeyD/6.1
243+
TEST_NAME: SECONDS, OP/SEC, OP/SEC/MHz, MEMORY
244+
01_math: 3.3808300495148, 591570.70030392, 164.32519452887, 4194304
245+
33_phpinfo_generate: 3.6759581565857, 2720.3791702809, 0.75566088063359, 4194304
246+
TOTAL: 7.0567882061005, 284832.12777484, 79.120035493011
247+
```

0 commit comments

Comments
(0)

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