本文介绍了PHP5性能比较,Windows和Linux的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我对Symfony2的性能有疑问.

I have a question about Symfony2 performance.

我已经在Ubuntu 11.04下使用Symfony2,Apache 2.2.17,PHP 5.3.5,APC 3.1.9,没有xDebug进行了开发

I have been developing with Symfony2 under Ubuntu 11.04 for a few weeks now, Apache 2.2.17, PHP 5.3.5, APC 3.1.9, no xDebug

在开发环境中,Symfony2工具栏上给出的时间从未超过70毫秒.

On the dev environment, the time given on the Symfony2 toolbar was never above 70 ms.

今天,我尝试在Windows 7环境中安装我的应用程序:Wampserver 2.2,PHP 5.3.8,Apache 2.2.21,APC 3.1.7,无xDebug

Today, I've tried to install my app on a Windows 7 environment : Wampserver 2.2, PHP 5.3.8, Apache 2.2.21, APC 3.1.7, no xDebug

Windows环境下的计算机比ubuntu上的计算机(SSD,四核等)要好得多.

The computer on the windows environment is much better than the one on ubuntu (SSD, Quad core, etc).

当我在开发环境上运行该应用程序时,工具栏总是显示至少300毫秒.

And when I run the application on the dev environment, the toolbar indicates always a minimum of 300 ms.

那么,你知道这怎么可能吗?

So, do you know how it is possible ?

谢谢!

找到有关该主题的链接: http://fossplanet.com/f6/%5Bsymfony-users%5D-symfony2-slow-windows-xp-116465/

EDIT : found a link about the subject : http://fossplanet.com/f6/%5Bsymfony-users%5D-symfony2-slow-windows-xp-116465/

我也注意到了file_exists函数的问题(使用webgrind).

I noticed the problem with the file_exists function too (using webgrind).

那么,有什么想法吗?

也许这个话题已经讨论过了,但是我很惊讶没有找到任何相关的东西.

Maybe the subject has already been discussed, but I was surprised not to find anything related.

推荐答案

TL; DR;将realpath_cache_size设置为> 1000

此PR中已解决的问题:尝试将PHP.ini的realpath_cache_size设置为> 1000的值最近添加了一个symfony要求来解决此问题: https://github.com/sensiolabs/SensioDistribution commit/cf0179711b24d84d4a29d71a4010540f4c990bd8

Edit 2: Problem solved in this PR: Try to set PHP.ini's realpath_cache_size to a value > 1000A symfony requirement was recently added fixing this issue: https://github.com/sensiolabs/SensioDistributionBundle/commit/cf0179711b24d84d4a29d71a4010540f4c990bd8

:我刚刚看到以下答案: https://stackoverflow.com/a/17914570/980547 当我在php.ini中将realpath_cache_size = 4096k设置为(!)时,它在Windows上将页面生成时间减少了4.

I just saw this answer: https://stackoverflow.com/a/17914570/980547And it decreased page generation time by 4 on windows when I set realpath_cache_size=4096k in my php.ini (!)

旧答案:

因此,我将两者与webgrind进行了比较:

So, I did a comparison between both with webgrind:

在Windows(快速计算机)上,名为app_dev.php:

On windows (fast computer), called app_dev.php:

因此,您可以看到Web工具栏显示了764ms的时间生成(由于xDebug和分析而增加,但仍然相关).Webgrind显示:

So you can see that the web toolbar shows a 764ms time generation (increased because of xDebug and profiling, but still relevant).Webgrind shows:

  • 651调用file_exists()的时间为232ms(很多时间!)
  • 603调用filemtime()(211ms)
  • 230次调用UniversalClassLoader-> loadClass()(119ms)
  • 230次调用UniversalClassLoader-> findFile()(38毫秒)

在Linux(速度较慢的计算机)上,app_dev.php:

On linux (slow computer), app_dev.php:

298ms的总生成时间(比Windows少两倍多).

298ms of total generation time (which is more than twice less than on windows).

  • 237次调用UniversalClassLoader-> findFile()(36毫秒=>少4倍)
  • 237次调用UniversalClassLoader-> loadClass()(20毫秒=>少2倍)
  • 623对file_exists()的调用(仅4毫秒!!)
  • 605调用了filemtime()(仅4毫秒!!)

问题似乎出在file_exists()和filemtime()上,它们在Windows上比在Linux上慢得多.在Windows上,PHP会在60%的时间内寻找具有file_exists,filemtime,loadClass或findFile的文件.那是一个已知的问题吗?

The problem seems to be file_exists() and filemtime(), which are much slower on windows than on Linux. On windows, PHP is looking for files with file_exists, filemtime, loadClass or findFile for 60% of the time. Is that a known problem ?

因此问题仅在于开发环境,在生产中,由于所有内容都已缓存,因此没有file_exists完成.

Edit : so the problem is only for the dev environment, in production no file_exists are done since everything is cached.

这篇关于PHP5性能比较,Windows和Linux的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-30 04:43