PHPUnit 性能/测试超时
我正在构建一个测试脚本来检查一组命令的性能。在测试失败之前,测试脚本需要让它运行特定的时间。
PHPUnit 3.5 中是否有与此功能等效的功能?如何使用它?
I am building a testing script which is checking the performance of a set of commands. The test script needs to let it run for a specific amount of time before failing the test.
I found the PerformanceTestCase in the PHPUnit documentation website, but when I tried to use it I realised that it's old functionality which hasn't been included within the new version. (That doc is PHPUnit 3.0, and my version is 3.5).
Is there an equivalent for this functionality within PHPUnit 3.5, and how do I use it?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
好吧,您可以简单地执行类似的操作
当然,这意味着您的命令在完成之前不会被中断。
IMO 单元测试并不是为了测试性能。
Well, you could simply do something like
Of course this means that your commands will not be interrupted before being finished.
And IMO unittests are not meant for testing performance.
我今天遇到了一个类似的问题 - 我需要测试在分配的时间内是否发生了外部 HTTP 调用。
我没有构建另一个循环或读取 $start 和 $end 时间读数 - 我公开了 timed_out 参数,详细信息请参见http://www.php.net/manual/en/function.stream-get-meta-data.php
I ran into a smiliar issue today - I needed to test an external HTTP call was occuring within the allocated time.
Rather than build another loop or take $start and $end time readings - I exposed the timed_out param, detailed here http://www.php.net/manual/en/function.stream-get-meta-data.php