如何测量mysql时间,php中SQL查询的时间和/或负载? [英] How can I measure mysql time, the time and / or load of an sql query in php?
本文介绍了如何测量mysql时间,php中SQL查询的时间和/或负载?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如果可能的话,我需要找到一些方法来衡量我的查询所花费的时间以及服务器上的负载.
I need to find some measure of how long my queries are taking and the load on the server if possible.
我怀疑它是否可行,但是我也想获得CPU使用率.
I doubt its possible, but I would like to gain the cpu usage too.
有什么想法吗?
推荐答案
PHP语法
$starttime = microtime();
$query = mysql_query("select * from table");
$endtime = microtime();
然后计算$ starttime和$ endtime之差.
Then calculate the difference between $starttime and $endtime.
这篇关于如何测量mysql时间,php中SQL查询的时间和/或负载?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文