使用 PHP 衡量(和改进)性能的最佳方法? [英] best way to measure (and refine) performance with PHP?

查看:29
本文介绍了使用 PHP 衡量(和改进)性能的最佳方法?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用的网站开始变得有点缓慢,我想对其进行改进.我认为问题出在 PHP 上,但我不能确定.如何查看功能执行需要多长时间?

A site I am working with is starting to get a little sluggish, and I would like to refine it. I think the problem is with the PHP, but I can't be sure. How can I see how long functions are taking to perform?

推荐答案

如果要测试执行时间:

<?php
    $startTime = microtime(true);  
    // Your content to test
    $endTime = microtime(true);  
    $elapsed = $endTime - $startTime;
    echo "Execution time : $elapsed seconds";
?>

这篇关于使用 PHP 衡量(和改进)性能的最佳方法?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆