现在的位置: 首页 -> PHP学习 -> yii2利用Profiling进行耗时分析

yii2利用Profiling进行耗时分析

2017-06-22 00:30评论数 0 ⁄ 被浏览 8907 views+

在yii2中可以利用Performance Profiling来查看代码执行耗时情况,有利于分析页面的性能瓶颈,具体位置在底部的Yii Debugger中(debug模式下才有)。


使用很简单,只需要对代码进行埋点就行了,可以嵌套使用,代码示例如下:


example1:

Yii::beginProfile('countryQueryCost');

这里是代码部分

Yii::endProfile('countryQueryCost');


example2:

Yii::beginProfile('totalCost');

这里是代码部分

Yii::beginProfile('sumCost');

可以嵌套使用哦

Yii::endProfile('sumCost');

Yii::endProfile('totalCost');


效果如下:

Performance Profiling

 

文章出自:https://www.daixiaorui.com/read/247.html 本站所有文章,除注明出处外皆为原创,转载请注明本文地址,版权所有。

目前有 0 条评论  @我要评论

    您的每一个评论都是对我的一份支持

     博客二维码

    昵称 *

    邮箱 *