Optimize my performance

前提是你 提交于 2019-12-05 05:55:38

If refactoring your code is not an option (drop Zend Framework, Drop Doctrine, Drop ...) I would first optimize in buying better hardware. That will automatically optimize your code, because the context of the code is just shifted (this is not exactly optimizing the code, as the code won't change).

If that is not an option consider to create yourself a build system that can pre-process your codebase and create a non-development version of it to cut the loading process. This requires the analysis which files are needed always and you compile them all into a loader-optimized format which could be single file and/or static class loader maps.

However it's known that Zend needs to load a lot into memory always. Even using a PHP cache like APC might already bring you something (consider to pre-compile with the earlier noted build script and optimize the parts highlighted by your metrics).

If your application structure allows it, there is another possibility, too: Keep your whole application in memory between requests. That can be done with a PHP webserver. That done, the code only needs to get loaded once the server starts and will never needed to load again. This only works with your own application if it supports multiple requests. A good encapsulated application especially with the request logic can be adopted quite easily for that. An existing solution is appserver-in-php. You will be amazed how much the speed increases compared to the benefits you already gained from APC.

Maybe this was helpful. Any additional, more concrete suggestions are hard to make as it's not possible to see your code in action nor to have detailed metrics on it. You've just passed a fragment on what's going behind the scenes so it's hard to tell you more concretely.

Mike Dunlavey

I'm trying to optimize performance using Xdebug & Webgrind

OK, since you're in a position of seriously needing better performance, you might be open to a less than popular, but demonstrably effective, way to do it.

It works with any language, as long as there's a debugger that can be paused, like Xdebug.

Here it is described in a nutshell. Here's one demonstration of its effectiveness. I can link you many more.

You might find it a little intellectually wrenching. As in

  1. You're finding "bottlenecks" as times associated with routines. The most valuable speedup opportunities often do not manifest that way. They are activities that you could easily describe when you see them, but they are diffuse. They do not concentrate significant time in any particular routine or line of code, so profilers don't see them.

  2. The biggest speedup opportunities may not be at all easy to fix. They may require a re-think of how the program is organized. If you find something you can easily fix, that's great. Go ahead and do it. If it is not so easily fixed, but will still save a lot of time, if you need to save that time, then you've gotta do it, like it or not.

Good luck.

I don't like what hakre is suggesting. First off I would look if I can drop the Webserver. If so a good alternative is nginx or lighttpd. Compared to the Apache they are from this century and also the configuration is a lot easier. About the autoloading I don't really know but if the class files a really big did you tried to install a ram disk or use a php compressor? In my experience a PHP compressor can significantly fasten the execution time (i.e. parsing time).

I have not too much experience but once I have had such problem. I have checked my include paths and resort them in the order of maximum used library paths. and I have got almost 30% boost. I think it is already known by you but have posted any way ....... :)

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!