评估我的PHP代码

时间:2011-03-18 08:12:05

标签: php profiling

我写了一个PHP应用程序,它从公共网站复制一些图片,但运行速度很慢。我想看看我有瓶颈的地方,或者花费最多的时间。我怎样才能做到这一点?

我正在使用Eclipse PDT作为IDE。有插件吗?

4 个答案:

答案 0 :(得分:2)

你应该尝试xdebug:http://www.xdebug.org/docs/profiler

以下是有关PDT和xdebug的文档:http://www.eclipse.org/pdt/documents/XDebugGuideForPDT2.0.pdf

答案 1 :(得分:2)

通常,从其他服务器读取/复制数据的代码会导致瓶颈。您可以使用以下代码来测量代码某些部分的时间,然后计算出来

<?php
$time_start = microtime(true);

// your slow code here...

$time_end = microtime(true);
$time = $time_end - $time_start;

echo "$time elapsed\n";
?>

答案 2 :(得分:2)

使用Webgrind检测瓶颈https://github.com/jokkedk/webgrind 它是XDebug分析的Web界面。

答案 3 :(得分:1)

在服务器端,Xdebug的安装,配置和使用都很复杂(在eclipse中),但一旦你理解它就很强大。

在客户端,在Firefox中,尝试Firebug;或者在Chrome中,尝试使用Chrome开发者工具来确定网页的哪些元素最需要加载。如果您在网站上使用高分辨率嵌入图像,或者作为评论者建议的网络联系时间,可能会出现简单的I / O问题。

相关问题