fruit / benchkit
此包最新版本(1.1.5)没有可用的许可信息。
受 Golang 启发的基准辅助工具
1.1.5
2016-12-01 10:02 UTC
Requires
Requires (Dev)
- fruit/chartkit: ~0.0
- pdepend/pdepend: *
- phploc/phploc: *
- phpmd/phpmd: *
- phpunit/phpunit: 4.0.*
- sebastian/phpcpd: *
- squizlabs/php_codesniffer: *
Suggests
- ext-xhprof: Required only if you are using xhprof
- fruit/chartkit: Required only if you are using HighChartSummary
- lox/xhprof: Required only if you are using xhprof
README
此包是 Fruit 框架的一部分。
BenchKit 是一组帮助你基准测试程序的工具。
概要
请参阅 example
文件夹中的 mybench.php
。
如何编写基准测试
基准测试必须是函数或公共方法。它必须接收一个具有类型提示的单个参数。
组织基准测试
基准测试根据它们的类分组。因此,建议将不同的基准测试组放入不同的文件中。
基准函数收集到一个未命名的组中。
命令行助手
bench
是命令行基准测试运行器。它将递归地扫描指定的目录,找到所有基准测试函数,并运行。例如
bench run example
感谢 CLIFramework,你可以运行 bench help run
来查看支持的命令行参数。
bench
不支持构造参数,你必须编写自己的基准测试执行器来注册基准测试并运行它。
XHProf
你可以通过启用 --xhprof
选项并使用 Fruit\BenchKit\Formatter\XhprofSummary
摘要格式化程序来在运行基准测试时收集 xhprof 数据。
- 启用
--xhprof
选项并 - 使用
Fruit\BenchKit\Formatter\XhprofSummary
摘要格式化程序。
向格式化程序传递构造函数参数
你可以通过使用 --sa
和 --pa
选项将字符串作为构造函数参数传递给格式化程序。
不运行基准测试多次生成多个摘要
使用 Fruit\BenchKit\Formatter\ChainSummary
,并传递构造函数参数来指定你想要的格式化程序。
bench run -s 'Fruit\BenchKit\Formatter\ChainSummary' --sa '{"chain":["Fruit\\BenchKit\\Formatter\\HighChartSummary":"{\"type\":\"time\"}", "Fruit\\BenchKit\\Formatter\\XhprofSummary":""]}' -p 'Fruit\BenchKit\Formatter\NullProgressLogger' example > /tmp/chart.html
注意 shell 转义和 PHP 字符串转义,因为内置格式化程序接受 JSON 格式的参数。当有疑问时,请使用 --argdebug
。
许可
任何版本的 MIT、GPL 或 LGPL。