我正在尝试将更多的计时信息输入到Symfony Profiler时间轴中,但我无法获得任何内容.根据我读过的文档,它应该像下面的示例一样简单,但这不会导致任何其他信息出现在时间轴上.
我是否需要以某种方式让分析器知道我正在开始和停止的事件?
use Symfony\Component\Stopwatch\Stopwatch;
class DefaultController extends Controller
{
public function testAction()
{
$stopwatch = new Stopwatch();
$stopwatch->start('testController');
usleep(1000000);
$response = new Response(
'<body>Hi</body>',
Response::HTTP_OK,
array('content-type' => 'text/html')
);
$event = $stopwatch->stop('testController');
return $response;
}
}
Run Code Online (Sandbox Code Playgroud)
Wou*_*r J 20
Symfony的探查器无法扫描所有秒表实例的代码并将其放入时间轴.您必须使用分析器提供的预配置秒表:
public function testAction()
{
$stopwatch = $this->get('debug.stopwatch');
$stopwatch->start('testController');
// ...
$event = $stopwatch->stop('testController');
return $response;
}
Run Code Online (Sandbox Code Playgroud)
但是,您的控制器已经在时间轴上......
| 归档时间: |
|
| 查看次数: |
2642 次 |
| 最近记录: |