Skip to content

The statistics greatly increase the interface time #1065

Open
@weibin3707811

Description

@weibin3707811

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions