使 PHP 性能分析可预测 [英] Making PHP performance profiling predictable

查看:54
本文介绍了使 PHP 性能分析可预测的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用 xdebug 和 PHP 进行一些性能分析.但是当我不止一次运行同一个脚本时,我经常得到非常不同的时间.所以很难知道对结果有多大信心.

I'm using xdebug with PHP to do some performance profiling. But when I run the same script more than once, I often get very different times. So it's hard to know how much faith to put in the results.

很明显,一台机器上发生的很多事情都会影响 PHP 的性能.但是我能做些什么来减少变量的数量,从而使多个测试更加一致?

Obviously there's a lot happening on a machine that can affect PHP's performance. But is there anything I can do to reduce the number of variables, so multiple tests are more consistent?

我在 Mac OS X 上的 Apache 下运行 PHP.

I'm running PHP under Apache, on Mac OS X.

推荐答案

  1. 尽可能减少盒子上无关服务的数量.
  2. 减少 Apache 进程的数量.
  3. 通过多次加载脚本来准备各种缓存.可能使用 Apache 的 absiege 等基准测试工具>,以确保所有 Apache 子进程都被命中.
  4. 使用 curlwget 从命令行分析您的脚本,以便 Apache 只提供一种资源:脚本本身.
  1. Reduce the number of unrelated services on the box as much as possible.
  2. Cut down on the number of Apache processes.
  3. Prime the various caches by loading your script a few times. Possibly use a benchmarking tool like Apache's ab or siege, to make sure all Apache children are hit.
  4. Profile your script from the command line using curl or wget so that Apache only serves one resource: the script itself.

通过省略其中一些步骤来获得更多真实世界"数字可能存在争议.我期待着这个问题可能会得到其他答案.

There may be an argument for getting more "real world" numbers by omitting some of these steps. I look forward to other answers this question may receive.

这篇关于使 PHP 性能分析可预测的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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