php-code-coverage icon indicating copy to clipboard operation
php-code-coverage copied to clipboard

The statistics greatly increase the interface time

Open weibin3707811 opened this issue 9 months ago • 3 comments

I reference pcov to statistics coverage, the original only 600ms interface, now increased to 8s to return

/**

  • 定义请求结束时执行的函数
  • @param CodeCoverage $coverage
  • @return void
  • @throws ReflectionException */ function __coverage_stop(CodeCoverage $coverage) { $coverage->stop(); $writer = new \SebastianBergmann\CodeCoverage\Report\PHP(); // 设置生成代码覆盖率页面的路径 $file_name = substr(md5(uniqid()), 0, 5); #获取请求接口的url $url = $SERVER['REQUEST_URI']; $file_name = $url .''. $file_name; $writer->process($coverage, dirname(FILE) . '/tmp/coverage/'. $file_name .'.cov'); } $filter = new \SebastianBergmann\CodeCoverage\Filter(); $driver = new \SebastianBergmann\CodeCoverage\Driver\PcovDriver($filter); $coverage = new CodeCoverage($driver, $filter); $id=substr(md5(uniqid()), 0, 15); $coverage->start($id,null,true); //开始统计 register_shutdown_function('__coverage_stop', $coverage); //注册函数关闭时的回调函数

weibin3707811 avatar Mar 18 '25 06:03 weibin3707811

I do not understand what you are trying to report.

sebastianbergmann avatar Mar 18 '25 06:03 sebastianbergmann

I do not understand what you are trying to report.

Is there a way to optimize to improve the response time of the interface after introduction

weibin3707811 avatar Mar 18 '25 06:03 weibin3707811

I do not understand which interface you refer to.

Collecting code coverage information has a significant impact on performance, no matter whether you use PCOV or Xdebug directly (without this library) or using this library.

sebastianbergmann avatar Mar 18 '25 06:03 sebastianbergmann