douxing6532 2010-11-03 01:28
浏览 12
已采纳

一个文件中的更多类 - 具有依赖性检查的生成器

I've profiled my code and realised, that Zend_Loader::loadClass takes a lot of time (like 100ms of each request). I see the point - being run for every class it's no surprise.

We already use opcode caching, but I want more. What I want to do is to merge frequently used classes to one file and require that file in bootstrap - thus having all the classes ready for use, minimising IO operations to minimum - autoloader won't be even fired ;)

Problem: There is a lot of classes that are required practically on every request (front controller, router, dispatcher, inflectors, controller abstract, helper broker, etc). Those classes have dependencies - their interfaces or abstract classes. I thought I would be able to make an automated tool to check for those dependencies, that would allow me to insert the classes into the file in propper order. Unfortunately autoloader doesn't load them in required order, but rather "as they come" in parsed code (for Zend_Form_Element: Z_F_Element_Text, Z_F_Element_Xhtml, Z_F_Element, ...) so dumping the classname in autoloader is no-go :(

Question: Do you use / is there a tool that would help in my case? I'd be happy to implement it myself if I had any abstract idea of how to do it.

  • 写回答

4条回答 默认 最新

  • duanpao4172 2012-06-24 16:12
    关注

    As of ZF2 automated tool exists. Thanks to EvanDotPro:

    https://github.com/EvanDotPro/EdpSuperluminal

    I also rough-ported it to ZF1 (please test first - may not be 100% working, but worked in my case):

    https://github.com/tomasfejfar/ZF1-superluminal

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(3条)

报告相同问题?