PHPUnit性能/测试超时

Ste*_* RC 1 phpunit

我正在构建一个测试脚本,它正在检查一组命令的性能.在测试失败之前,测试脚本需要让它运行一段特定的时间.

我在PHPUnit文档网站上找到了PerformanceTestCase,但是当我尝试使用它时,我发现它的旧功能尚未包含在新版本中.(该文档是PHPUnit 3.0,我的版本是3.5).

PHPUnit 3.5中是否存在此功能的等效物,我该如何使用它?

won*_*nk0 7

好吧,你可以简单地做点什么

public function testFoo() {
 $tStart = microtime( true );
 // your time critical commands
 $tDiff = microtime( true ) - $tStart;
 $this->assertLessThan( $maxTime, $tDiff, 'Took too long' );
}
Run Code Online (Sandbox Code Playgroud)

当然这意味着您的命令在完成之前不会被中断.

IMO单元测试不适用于测试性能.