0

recently I take a old project to rebuild.

I find the old source is so bad And I decide to reconsitution All project.

I try rewrite one module to test.

finnally I have Done coding and running this code in PHP5.6 environment and use xhprof to test performance to compare with old source.

but the new code's performance is not promote obviously. even cut down...

I find Top consume what is compose's autoload.

why??

OLD_SOURCE:
wt(wall time) 1,056,607 µs
cpu(cpu time) 370,198 µs
mu(memory useage) 6,342,688 bytes

NEW_SOURCE:
wt(wall time) 1,333,805 µs
cpu(cpu time) 868,354 µs
mu(memory useage) 3,668,944 bytes

As described.

In new Source

wallt time is up.
cpu time is up.
memory useage is down.

In details:

PDOStatement::execute
181,289 µs
Composer\Autoload\includeFile@1
156,924 µs
Composer\Autoload\includeFile
134,179 µs
file_exists
104,139 µs

In new code,I used MySQL PDO.
In old code,Is use MySQLi.
I can understand MySQLi fast to PDO.

but why Composer\Autoload\includeFile@1 Composer\Autoload\includeFile occupy more time to effected code??

and i find the func file_exists who is in Composer\Autoload\ClassLoader::findFileWithExtension

top3/4 question func in composer....

dan.liu
  • 11
  • 1
  • 1
    can you use php 7.2? also, check answers to previous questions: https://stackoverflow.com/questions/31103521/zend-framework-2-composer-autoload-includefile-is-slow https://stackoverflow.com/questions/39478418/improve-composer-autoload-includefile-in-symfony – Brian Dec 07 '17 at 04:18
  • i can's use 7.2 because to compatible old code.and i use composer with guzzle and eloquent plugs. – dan.liu Dec 07 '17 at 05:01

1 Answers1

0

i find change opcache's setting

; Allow file existence override (file_exists, etc.) performance feature. opcache.enable_file_override=1

can improve my code. use before:
wall time: 1,300,687 µs
cpu time: 759,489 µs

use after:
wall time: 771,002 µs
cpu time: 429,664 µs

amazing@_@

dan.liu
  • 11
  • 1