tankfairies/benchmark
最新稳定版本:1.3
Composer 安装命令:
composer require tankfairies/benchmark
包简介
benchmark code
关键字:
README 文档
README
Benchmark
Provides the ability to do simple performance tests on code blocks.
Installation
Install with Composer:
composer require tankfairies/benchmark
Usage
Server Details
This will output an array of basic details on the machine you're running performance testing on.
For server details: -
$server = new Server(); $details = $server->getDetails();
Output Example: -
Array ( [PHP] => 8.2.16 [Platform] => Darwin [Arch] => arm64 [Max memory usage] => 128M [OPCache status] => disabled [OPCache JIT] => disabled/unavailable [PCRE JIT] => enabled [XDebug extension] => disabled )
For installed extensions: -
$server = new Server(); $extensions = $server->getInstalledExtensions();
Output Example: -
Array
(
[0] => Core
[1] => date
[2] => libxml
[3] => openssl
[4] => pcre
[5] => sqlite3
[6] => zlib
[7] => bcmath
...
Stopwatch
Handles the time recording for benchmarking.
Benchmark
Call or place the code you want to test into an anonymous function, for example: -
$func = function () { rand(1, 100000); };
Setup the benchmark as below: -
$benchmark = new Benchmark(new Stopwatch()); $completion = $benchmark ->multiplier(200000, 5) ->script($func) ->run();
You can define your own run criteria for example the above will run the test 200000 times for a total of 5 loops. This will produce 5 sets of results in seconds in the format: -
Array ( [1] => 0.1699 [2] => 0.1642 [3] => 0.1641 [4] => 0.1643 [5] => 0.1645 )
The above shows the execution time in seconds for each 200k run.
Copyright and license
The tankfairies/benchmark library is Copyright (c) 2019 Tankfairies (https://tankfairies.com) and licensed for use under the MIT License (MIT).
统计信息
- 总下载量: 7
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 0
- 依赖项目数: 1
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2024-03-19