基准化PHP页面加载时间 [英] Benchmarking PHP page load times

查看:66
本文介绍了基准化PHP页面加载时间的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何测量加载页面(使用各种不同的PHP语句)所花费的时间?

How could I measure the time taken to load a page (with various different PHP statements)?

有点像这里提供的统计信息- http://talks.php.net/show/drupal08/24

Somewhat like the stats available here - http://talks.php.net/show/drupal08/24

推荐答案

最简单的方法也是

The most simple too is Apache Bench (called ab), which is provided with Apache :

  • 这是一个命令行工具
  • 可以同时向和URL发送许多请求
  • 并报告时间,错误等...

似乎适合幻灯片上显示的那种非常简单的报告.
(实际上报告的还不止于此)

Seems to fit the kind of very simple reporting that's presented on your slide.
(It does actually report more than that)


如果您的需求更加复杂,
围攻可以是一个不错的选择.


If your needs ar ea bit more complex, Siege can be a good alternative.

Siege的有趣之处在于,它可以从文件中获取URL列表,而不是仅使用一个URL.

An interesting thing with Siege is that it can take a list of URLs from a file, instead of working with just one.


这些工具的有趣之处在于,您不只是在测量执行代码的特定部分所花费的时间(就像使用,直接在您的PHP代码中="=" noreferrer> microtime ).


An interesting thing with those tools is that you are not measuring only the time taken to execute a specific portion of code (like you would if using microtime directly in your PHP code), but you're getting the whole time that was required to serve the page.

此外,由于它可以处理HTTP请求,因此它不仅可以对PHP代码进行基准测试,还可以对代码本身进行基准测试.

Also, it can benchmark more than just PHP code, as it's working on the HTTP request, and not the code itself.

这篇关于基准化PHP页面加载时间的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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