使用blackfire.io分析PHP 7应用程序,为什么我看到相同代码的不同CPU时间?

I support and rework legacy PHP7 application. This application don't use autoloading, instead of this aplication require all classes in single file, just going round all directories with classes. Old team thought that it is great optimization way.

So i did some tests with blackfire, and found that this including can consume half of cpu's time. I did experiments with autoload and reduce cpu time in two times and memory consumption in three times. Great result.

Then i continued experiments with old code without autoload and found that in some cases mega-including does not consume a lot of time (and it's flat file with a lot of loops, no if-else statements).

In blackfire panel this looks like that file with includes have very distinguished numbers of callees. In one case this file have 21 callees and work 132 ms, in another case its 6 callees and 2.63 ms.

And i dont understand reason of such difference. My assumption is that PHP7 very smart and can analyze which classes really should be compiled in byte code and which not.

Does somebody know why such difference exists?

PS: I can't show blackfire reports, PM don't allow this.

Without the code or reports is hard to guess. But I would take a look to this page. Maybe things that are explained there are present in the code that you are reviewing.

https://blackfire.io/docs/24-days/22-php-internals