{"id":16674804,"url":"https://github.com/sergix44/php-benchmark-script","last_synced_at":"2025-08-19T13:14:41.919Z","repository":{"id":94488270,"uuid":"590048779","full_name":"sergix44/php-benchmark-script","owner":"sergix44","description":"A simple PHP script that helps you compare raw performance across servers and php versions","archived":false,"fork":false,"pushed_at":"2024-11-21T09:27:46.000Z","size":60,"stargazers_count":42,"open_issues_count":2,"forks_count":10,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-04-02T01:41:29.646Z","etag":null,"topics":["bench","benchmark","benchphp","performance","performance-testing","php","phpbench","script"],"latest_commit_sha":null,"homepage":"","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/sergix44.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","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},"funding":{"github":["SergiX44"],"patreon":null,"open_collective":null,"ko_fi":null,"tidelift":null,"community_bridge":null,"liberapay":null,"issuehunt":null,"otechie":null,"lfx_crowdfunding":null,"custom":null}},"created_at":"2023-01-17T14:47:36.000Z","updated_at":"2025-02-07T13:11:25.000Z","dependencies_parsed_at":"2024-01-23T21:56:36.925Z","dependency_job_id":"db1b280b-54de-46b5-971f-bb689b93687f","html_url":"https://github.com/sergix44/php-benchmark-script","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/sergix44/php-benchmark-script","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sergix44%2Fphp-benchmark-script","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sergix44%2Fphp-benchmark-script/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sergix44%2Fphp-benchmark-script/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sergix44%2Fphp-benchmark-script/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/sergix44","download_url":"https://codeload.github.com/sergix44/php-benchmark-script/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sergix44%2Fphp-benchmark-script/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":271158621,"owners_count":24709102,"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","status":"online","status_checked_at":"2025-08-19T02:00:09.176Z","response_time":63,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":["bench","benchmark","benchphp","performance","performance-testing","php","phpbench","script"],"created_at":"2024-10-12T12:44:24.428Z","updated_at":"2025-08-19T13:14:41.894Z","avatar_url":"https://github.com/sergix44.png","language":"PHP","funding_links":["https://github.com/sponsors/SergiX44"],"categories":[],"sub_categories":[],"readme":"# PHP Benchmark Script\n\nA simple script that calculate execution time of common control flows\nand function of the PHP. Helps you to compare performances of servers,\nweb hosting and also across PHP versions.\n\n## Usage\n\nFrom your SSH:\n\n```sh\ncurl https://raw.githubusercontent.com/SergiX44/php-benchmark-script/master/bench.php | php\n```\n\nOr upload the file `bench.php` to your web document root and visit it.\n\n#### Parameters\n\nYou can change the difficulty multiplier by passing a `multiplier` parameter:\n\n```sh\nphp bench.php --multiplier=2\n```\n\n### Additional tests\n\nYou must have the `bench.php` file to your server.\nYou can download additional benchmarks (must be in the same directory as `bench.php`) using:\n\nAvailable tests:\n```sh\n# rand: random number generation\nwget https://raw.githubusercontent.com/SergiX44/php-benchmark-script/master/rand.bench.php\n# io: file read/write/zip/unzip\nwget https://raw.githubusercontent.com/SergiX44/php-benchmark-script/master/io.bench.php\n# mysql: selects, updates, deletes, transactions, ....\n# you need to pass the args --mysql_user=xxx --mysql_password=xxx --mysql_host=xxx (optional: --mysql_port=xxx --mysql_database=xxx)\nwget https://raw.githubusercontent.com/SergiX44/php-benchmark-script/master/mysql.bench.php\n```\n\nThen you can run the benchmark using:\n\n```sh\nphp bench.php\n```\n\nIf the file is in the same directory as `bench.php`, it will be automatically loaded.\n\n## Custom tests\n\nYou can create your own tests by creating a file in the same directory as `bench.php` and the file must be\nnamed `*.bench.php`.\n\nThe file must return a closure, or an array of closures. Each closure should take a parameter `$multiplier` which is\nhow hard the test should be. The higher the `$multiplier`, the longer the test will take, by default it is `1`.\nYou should choose a reasonable number of iterations for your test (e.g. 1000) and multiply it by the `$multiplier`.\n\nExample:\n\n```php\n// mytest.bench.php\n\nreturn function ($multiplier = 1) {\n    $iterations = 1000 * $multiplier;\n    for ($i = 0; $i \u003c $iterations; ++$i) {\n        // do something\n    }\n};\n```\n\nOr with multiple tests:\n\n```php\n// mytest.bench.php\n\nreturn [\n    'my_test' =\u003e function ($multiplier = 1) {\n        $iterations = 1000 * $multiplier;\n        for ($i = 0; $i \u003c $iterations; ++$i) {\n            // do something\n        }\n    },\n    'another_test' =\u003e function ($multiplier = 1) {\n        $iterations = 1000 * $multiplier;\n        for ($i = 0; $i \u003c $iterations; ++$i) {\n            // do something else\n        }\n    },\n];\n```\n\n# Example Output\n\n```sh\n-------------------------------------------------------\n|       PHP BENCHMARK SCRIPT v.2.0 by @SergiX44       |\n-------------------------------------------------------\nPHP............................................. 8.2.10\nPlatform........................................ Darwin\nArch............................................. arm64\nServer........................................ hostname\nMax memory usage.................................. 512M\nOPCache status................................. enabled\nOPCache JIT.................................... enabled\nPCRE JIT....................................... enabled\nXDebug extension.............................. disabled\nDifficulty multiplier............................... 1x\nStarted at..................... 06/12/2023 13:45:37.453\n-------------------------------------------------------\nmath.......................................... 0.0935 s\nloops......................................... 0.0121 s\nifelse........................................ 0.0173 s\nswitch........................................ 0.0172 s\nstring........................................ 0.1842 s\narray......................................... 0.3212 s\nregex......................................... 0.1769 s\nis_{type}..................................... 0.0322 s\nhash.......................................... 0.1202 s\njson.......................................... 0.1586 s\n-----------------Additional Benchmarks-----------------\nio::file_read................................. 0.0129 s\nio::file_write................................ 0.0715 s\nio::file_zip.................................. 0.5335 s\nio::file_unzip................................ 0.1571 s\nrand::rand.................................... 0.0089 s\nrand::mt_rand................................. 0.0089 s\nrand::random_int.............................. 0.0679 s\nrand::random_bytes............................ 0.2320 s\nrand::openssl_random_pseudo_bytes............. 0.2953 s\n-------------------------------------------------------\nTotal time.................................... 2.5214 s\nPeak memory usage................................ 2 MiB\n```\n\n## Authors\n\n- [@SergiX44](https://www.github.com/SergiX44)\n\n## License\n\n[MIT](https://choosealicense.com/licenses/mit/)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsergix44%2Fphp-benchmark-script","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsergix44%2Fphp-benchmark-script","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsergix44%2Fphp-benchmark-script/lists"}