{"id":15022471,"url":"https://github.com/rusoft/php-simple-benchmark-script","last_synced_at":"2025-04-09T07:09:15.215Z","repository":{"id":98101987,"uuid":"88910125","full_name":"rusoft/php-simple-benchmark-script","owner":"rusoft","description":"Очень простой скрипт тестирования быстродействия PHP | Very simple script for testing of PHP operations speed (rusoft repo mirror)","archived":false,"fork":false,"pushed_at":"2025-03-26T08:18:09.000Z","size":199,"stargazers_count":63,"open_issues_count":4,"forks_count":27,"subscribers_count":7,"default_branch":"master","last_synced_at":"2025-04-02T06:07:01.741Z","etag":null,"topics":["benchmark","php","php4","php5","php7","php8"],"latest_commit_sha":null,"homepage":"","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/rusoft.png","metadata":{"files":{"readme":"README.en.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2017-04-20T21:00:57.000Z","updated_at":"2025-03-26T08:18:13.000Z","dependencies_parsed_at":"2025-01-28T14:34:08.219Z","dependency_job_id":"6b79f755-2f5d-401a-9a70-84a6d2b9875b","html_url":"https://github.com/rusoft/php-simple-benchmark-script","commit_stats":null,"previous_names":[],"tags_count":59,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rusoft%2Fphp-simple-benchmark-script","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rusoft%2Fphp-simple-benchmark-script/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rusoft%2Fphp-simple-benchmark-script/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rusoft%2Fphp-simple-benchmark-script/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/rusoft","download_url":"https://codeload.github.com/rusoft/php-simple-benchmark-script/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247994121,"owners_count":21030050,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["benchmark","php","php4","php5","php7","php8"],"created_at":"2024-09-24T19:58:00.089Z","updated_at":"2025-04-09T07:09:15.198Z","avatar_url":"https://github.com/rusoft.png","language":"PHP","readme":"# A simple PHP script to test speed\n\nWorks with all versions of PHP: from 4.3 to 8.2\n\n## Dependencies\n\nRequired modules for full php testing:\n\n- pcre\n- mbstring\n- json\n- dom\n- simplexml\n- intl\n\nUsually they are already installed or \"compiled\" in php.\n\nHow to check it:\n\n- in console: `php -m`\n- or via function `phpinfo()` output\n\n### Modules affecting test results\n\n- xdebug - can slow down most of the tests by half, and some related to error handling - by 10!\n- opcache - can cache the execution of functions, or throw out \"not affecting execution\" pieces of code\n- other opcode accelerators: xcache, apc, eaccelerator, etc.\n\n## Startup\n\n### 0. Files\n\nYou need to put these files in one directory: `bench.php`, `common.inc`, `php5.inc`, `php7.inc`, `test.xml`.\n\n### 1. Through the console\n\nCommand:\n```\nUsage: bench.php [-h|--help] [-x|--debug] [-C|--dont-use-colors] [-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 ...]\n\n\t-h|--help\t\t- print this help and exit\n\t-x|--debug\t\t- enable debug mode, raise output level\n\t-C|--dont-use-colors\t- disable printing html-span or color sequences for capable terminal: xterm, *-color, *-256color. And not in JSON/machine mode.\n\t-J|--print-json\t- enable printing only in JSON format, useful for automated tests. disables print-machine.\n\t-M|--print-machine\t- enable printing only in machine parsable format, useful for automated tests. disables print-json.\n\t-d|--dont-recalc\t- do not recalculate test times / operations count even if memory of execution time limits are low\n\t-D|--dumb-test-print\t- print dumb test time, for debug purpose\n\t-L|--list-tests\t\t- output list of available tests and exit\n\t-I|--system-info\t- output system info but do not run tests and exit\n\t-m|--memory-limit \u003cMb\u003e\t- set memory_limit value in Mb, defaults to 130 (Mb)\n\t-t|--time-limit \u003csec\u003e\t- set max_execution_time value in seconds, defaults to 600 (sec)\n\t-T|--run-test \u003cname\u003e\t- run selected test, test names from --list-tests output, can be defined multiple times\n```\nExample: `php bench.php -m=64 -t=30`\n\nThe second option for passing values ​​for parameters is environment variables:\n```\nenv PHP_MEMORY_LIMIT=64 PHP_TIME_LIMIT=30 php bench.php\n```\n\nAvailable variables:\n\n- PHP_TIME_LIMIT=\u003cSeconds\u003e\n- PHP_DEBUG_MODE=0/1\n- DONT_USE_COLORS=0/1\n- PRINT_JSON=0/1\n- PRINT_MACHINE=0/1\n- PHP_MEMORY_LIMIT=\u003cМб\u003e\n- DONT_RECALCULATE_LIMITS=0/1\n- LIST_TESTS=0/1\n- SYSTEM_INFO=0/1\n- RUN_TESTS=test1,test2,...\n\n#### Extras (Utilities in Linux)\n\n- You can set the priority of a process with the command `nice` - от -20 (high) до 19 (low). For example, priority 5: `nice -5 php bench.php`. Read `man nice`.\n- You can set I/O priority with the command `ionice`. Example: `ionice -c3 php bench.php`. Read `man ionice`.\n- You can bind script execution to the processor core with the command `taskset`. Example: `taskset -c -p 0 php bench.php`. Read `man taskset`.\n- Вы можете комбинировать команды: `taskset -c -p 0 nice -10 ionice -c3 php bench.php`.\n\n### 2. Through web servers (apache + php)\n\nJust put in any php directory of the site available for execution, for example, in the root.\n\nThen the script can be called with parameters, as from the console:\n`curl http://www.example.com/bench.php?memory_limit=64\u0026time_limit=30`\nor via browser.\n\nAvailable options:\n\n- time_limit=Секунды\n- debug_mode=0/1\n- dont_use_colors=0/1\n- print_json=0/1\n- print_machine=0/1\n- memory_limit=Мб\n- dont_recalculate_limits=0/1\n- list_tests=0/1\n- system_info=0/1\n- run_tests=test1,test2,...\n\n### Accounting for hosting options\n\nOn many hostings, the `memory_limit` and `max_execution_time` parameters can be hardcoded.\n\nIn this case, the script will not be able to set the parameter values passed to it, at least not above the limits.\n\nThe script execution time will be recalculated according to the smallest resulting values.\n\n### Other platforms\n\nFor example, on Raspberry Pi 2B, 3B and other similar boards, the execution speed is so slow,\nthat you have to specify the `-d -t 3600` options to make all the tests pass.\n\nThis applies to all ARM, MIPS, etc. As well as old AMD and Intel processors like Celeron, Atom, Duron, etc.\n\n## Example script output\n\n### Generic format\n\n```\n\u003c\u003c\u003c WARNING \u003e\u003e\u003e You need to disable Xdebug extension! It greatly slow things down! And mess with PHP internals.\n\u003c\u003c\u003c WARNING \u003e\u003e\u003e Execution time limit not droppped to '600' seconds!\nScript will have only '0' seconds to run.\n\u003c\u003c\u003c WARNING \u003e\u003e\u003e Extension 'xdebug' loaded! It will affect results and slow things greatly! Even if not enabled!\n\u003c\u003c\u003c WARNING \u003e\u003e\u003e Set xdebug.mode in php.ini / VHost or FPM config / php_admin_value or via cmd '-dxdebug.mode=off' option of PHP executable.\n\n-------------------------------------------------------------------------------------------\n|                                  PHP BENCHMARK SCRIPT                                   |\n-------------------------------------------------------------------------------------------\nStart               : 2022-05-03 18:22:49\nServer              : Linux/5.4.0-104-lowlatency x86_64\nPlatform            : Linux\nSystem              : Ubuntu 18.04.6 LTS\nCPU                 :\n              model : Intel(R) Core(TM) i5-6600K CPU @ 3.50GHz\n              cores : 4\n          available : 4\n                MHz : 3600 MHz\nBenchmark version   : 1.0.51\nPHP version         : 7.4.29-SergeyD/6.1\nPHP time limit      : 0 sec\nSetup time limit    : 600 sec\nPHP memory limit    : 128M\nSetup memory limit  : 130 Mb\nCrypt hash algo     : MD5\n     Loaded modules\n          -useful-\u003e\n               json : yes\n           mbstring : yes;\n               pcre : yes; version: 10.39 2021-10-29\n          simplexml : yes; libxml version: 2.9.4\n                dom : yes\n               intl : yes; icu version: 66.1\n       -affecting-\u003e\n            opcache : yes; enabled: 0\n             xcache : no; enabled: 0\n                apc : no; enabled: 0\n       eaccelerator : no; enabled: 0\n             xdebug : yes, enabled: 1, mode: 'develop'\n     PHP parameters\n       open_basedir : is empty? yes\n   mb.func_overload : 0\n-------------------------------------------------------------------------------------------\nTEST NAME                      :      SECONDS |       OP/SEC |      OP/SEC/MHz |    MEMORY\n-------------------------------------------------------------------------------------------\n01_math                        :    2.958 sec | 676.22 kOp/s | 178.48  Ops/MHz |      4 Mb\n02_string_concat               :    1.683 sec |  14.86 MOp/s |   3.92 kOps/MHz |  89.83 Mb\n03_1_string_number_concat      :    1.544 sec |   3.24 MOp/s | 854.83  Ops/MHz |      4 Mb\n03_2_string_number_format      :    1.348 sec |   3.71 MOp/s | 979.33  Ops/MHz |      4 Mb\n04_string_simple_functions     :    1.320 sec | 984.64 kOp/s | 259.88  Ops/MHz |      4 Mb\n05_string_multibyte            :    1.061 sec | 122.47 kOp/s |  32.32  Ops/MHz |      4 Mb\n06_string_manipulation         :    2.397 sec | 542.37 kOp/s | 143.15  Ops/MHz |      4 Mb\n07_regex                       :    2.035 sec | 638.84 kOp/s | 168.61  Ops/MHz |      4 Mb\n08_1_hashing                   :    2.030 sec | 640.31 kOp/s | 169.00  Ops/MHz |      4 Mb\n08_2_crypt                     :    8.698 sec |   1.15 kOp/s |   0.30  Ops/MHz |      4 Mb\n09_json_encode                 :    2.322 sec | 559.91 kOp/s | 147.78  Ops/MHz |      4 Mb\n10_json_decode                 :    3.556 sec | 365.54 kOp/s |  96.48  Ops/MHz |      4 Mb\n11_serialize                   :    1.551 sec | 838.30 kOp/s | 221.25  Ops/MHz |      4 Mb\n12_unserialize                 :    1.677 sec | 774.97 kOp/s | 204.54  Ops/MHz |      4 Mb\n13_array_fill                  :    3.740 sec |  24.07 MOp/s |   6.35 kOps/MHz |     24 Mb\n14_array_range                 :    2.007 sec |  74.74 kOp/s |  19.73  Ops/MHz |     24 Mb\n14_array_unset                 :    2.833 sec |  31.77 MOp/s |   8.38 kOps/MHz |     24 Mb\n15_clean_loops                 :    1.342 sec | 298.14 MOp/s |  78.69 kOps/MHz |      4 Mb\n16_loop_ifelse                 :    1.992 sec |  50.20 MOp/s |  13.25 kOps/MHz |      4 Mb\n17_loop_ternary                :    3.057 sec |  32.71 MOp/s |   8.63 kOps/MHz |      4 Mb\n18_1_loop_defined_access       :    1.017 sec |  49.15 MOp/s |  12.97 kOps/MHz |      4 Mb\n18_2_loop_undefined_access     :    4.729 sec |  10.57 MOp/s |   2.79 kOps/MHz |      4 Mb\n19_type_functions              :    1.152 sec |   3.47 MOp/s | 916.65  Ops/MHz |      4 Mb\n20_type_casting                :    1.178 sec |   3.39 MOp/s | 895.86  Ops/MHz |      4 Mb\n21_0_loop_exception_none       :    0.204 sec |  48.94 MOp/s |  12.92 kOps/MHz |      4 Mb\n21_1_loop_exception_try        :    0.212 sec |  47.21 MOp/s |  12.46 kOps/MHz |      4 Mb\n21_2_loop_exception_catch      :    3.214 sec |   3.11 MOp/s | 821.23  Ops/MHz |      4 Mb\n22_loop_null_op                :    1.266 sec |  47.41 MOp/s |  12.51 kOps/MHz |      4 Mb\n23_loop_spaceship_op           :    1.202 sec |  49.93 MOp/s |  13.18 kOps/MHz |      4 Mb\n26_1_class_public_properties   :    0.133 sec |  75.10 MOp/s |  19.82 kOps/MHz |      4 Mb\n26_2_class_getter_setter       :    0.425 sec |  23.54 MOp/s |   6.21 kOps/MHz |      4 Mb\n26_3_class_magic_methods       :    1.189 sec |   8.41 MOp/s |   2.22 kOps/MHz |      4 Mb\n27_simplexml                   :    4.121 sec |  12.13 kOp/s |   3.20  Ops/MHz |      4 Mb\n28_domxml                      :    4.228 sec |  11.83 kOp/s |   3.12  Ops/MHz |      4 Mb\n29_datetime                    :    0.571 sec | 875.87 kOp/s | 231.17  Ops/MHz |      4 Mb\n30_intl_number_format          :    0.826 sec |  24.22 kOp/s |   6.39  Ops/MHz |      4 Mb\n31_intl_message_format         :    4.236 sec |  47.22 kOp/s |  12.46  Ops/MHz |      4 Mb\n32_intl_calendar               :    0.844 sec | 355.34 kOp/s |  93.79  Ops/MHz |      4 Mb\n33_phpinfo_generate            :    1.440 sec |   6.95 kOp/s |   1.83  Ops/MHz |      4 Mb\n-------------------------------------------------------------------------------------------\nTotal time:                    :   81.337 sec |  13.73 MOp/s |   3.62 kOps/MHz |\nCurrent PHP memory usage:      :        4 Mb\nPeak PHP memory usage:         :    86.58 Mb\n```\n\n### JSON-format\n\nCommand: `php74 -derror_log= -dxdebug.mode=off bench.php -T 01_math -T 33_phpinfo_generate -J`\n```\n{ \n\"php_benchmark_script\": \"1.0.51\",\n\"start\": \"2022-05-03 22:11:19\",\n\"server\": \"Linux/5.4.0-104-lowlatency x86_64\",\n\"system\": \"Ubuntu 18.04.6 LTS\",\n\"php_version\": \"7.4.29-SergeyD/6.1\",\n\"results\": {\n  \"columns\": [ \"test_name\", \"seconds\", \"op\\/sec\", \"op\\/sec\\/MHz\", \"memory\" ],\n  \"rows\": [\n    [ \"01_math\", 3.4119508266449, 586174.91916397, 162.82636643444, 4194304 ],\n    [ \"33_phpinfo_generate\", 3.6402199268341, 2747.0867697538, 0.76307965826494, 4194304 ],\n    null\n  ]\n},\n\"total\": { \"seconds\": 7.052170753479, \"op\\/sec\":285018.62338039, \"op\\/sec\\/MHz\":79.171839827885 },\n\"messages_count\": 0,\n\"end\":true\n}\n```\n\n### Machine-parsable format\n\nCommand: `php74 -derror_log= -dxdebug.mode=off bench.php -T 01_math -T 33_phpinfo_generate -M`\n```\nPHP_BENCHMARK_SCRIPT: 1.0.51\nSTART: 2022-05-03 22:11:52\nSERVER: Linux/5.4.0-104-lowlatency x86_64\nSYSTEM: Ubuntu 18.04.6 LTS\nPHP_VERSION: 7.4.29-SergeyD/6.1\nTEST_NAME: SECONDS, OP/SEC, OP/SEC/MHz, MEMORY\n01_math: 3.3808300495148, 591570.70030392, 164.32519452887, 4194304\n33_phpinfo_generate: 3.6759581565857, 2720.3791702809, 0.75566088063359, 4194304\nTOTAL: 7.0567882061005, 284832.12777484, 79.120035493011\n```\n\n### In web-browser\n\nLink like: http://sergey.home.lan/bench/bench.php?system_info=1\n![System information](browser.png \"System information\")\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frusoft%2Fphp-simple-benchmark-script","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frusoft%2Fphp-simple-benchmark-script","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frusoft%2Fphp-simple-benchmark-script/lists"}