我注意到当我有一个无限的worker时,我无法对PHP shell脚本进行性能分析。因为当它被杀死时,它不会发送探针。
我应该做哪些改变?
我应该做哪些改变?
// Get the probe main instance
$probe = BlackfireProbe::getMainInstance();
// start profiling the code
$probe->enable();
// Calling close() instead of disable() stops the profiling and forces the collected data to be sent to Blackfire:
// stop the profiling
// send the result to Blackfire
$probe->close();
与自动仪器化一样,分析只有在通过 Companion 或 blackfire CLI 实用程序运行代码时才处于活动状态。否则,所有调用均转换为 noop。
我不知道,也许在2015年这个页面不存在,但现在你可以通过以下方式进行分析:https://blackfire.io/docs/24-days/17-php-sdk
$blackfire = new LoopClient(new Client(), 10);
$blackfire->setSignal(SIGUSR1);
$blackfire->attachReference(7);
$blackfire->promoteReferenceSignal(SIGUSR2);
for (;;) {
$blackfire->startLoop($profileConfig);
consume();
$blackfire->endLoop();
usleep(400000);
}
LoopClient
将开始分析。它会监听方法consume
的10次迭代并发送最后一个探测值。之后它将停止分析。