burntcaramel / stir
记录您网站上的耗时。
1.0
2014-05-23 11:15 UTC
Requires
- php: >=5.3.0
This package is not auto-updated.
Last update: 2024-09-24 06:26:34 UTC
README
记录您PHP网站上的耗时,并以HTML或JSON格式显示。
轻松启用和禁用
(当stir被禁用时,它回退到安全使用的空函数)
// For example in WordPress, only enable if an administrator user is logged in. define ('STIR_ENABLED', current_user_can('administrator'));
测量时间
// Start measuring: function displayPage() // example template function { stir('display page'); displayHTMLHead(); stirring('display page', 'html head'); displayNavigation(); stirring('display page', 'nav'); $articles = retrieveLatestArticles(); $articleIndex = 0; foreach ($articles as $article): stir('display article'); displayArticle($article); stirred('display article'); $articleIndex++; endforeach; stirring('display page', 'articles'); displayFooter(); stirring('display page', 'footer'); displayHTMLEnd(); stirred('display page'); }
以HTML显示记录的时间
// End of page. stirDisplayRecordedTimesForHTML(); ?> </body> </html> <?php
以JSON响应显示记录的时间
$action = 'get-user-favorites'; $info = getInfoForUserFavorites(); // The following function still works when stir is set to disabled. stirDisplayJSONInfo($info, $action);