Skip to content

The statistics greatly increase the interface time #1065

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
weibin3707811 opened this issue Mar 18, 2025 · 3 comments
Open

The statistics greatly increase the interface time #1065

weibin3707811 opened this issue Mar 18, 2025 · 3 comments

Comments

@weibin3707811
Copy link

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); //注册函数关闭时的回调函数
@sebastianbergmann
Copy link
Owner

I do not understand what you are trying to report.

@weibin3707811
Copy link
Author

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

@sebastianbergmann
Copy link
Owner

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants