Skip to content

Latest commit

 

History

History
53 lines (35 loc) · 2.06 KB

README.md

File metadata and controls

53 lines (35 loc) · 2.06 KB

Performance

Composer's vendor/autoload.php file requires all Safe files on each request (since there is no autoloading for functions in PHP).

"Requiring" those ~84 files in PHP has a performance impact. We used Blackfire to time precisely the impact of loading the PHP files.

Results

Composer autoload without Safe 264µs
Composer autoload with Safe 1.03ms 

Safe load time: ~700µs

Only 700µs for loading 84 files containing 1000+ functions. Damn, PHP is fast! Opcache does a very good job.

The tests have been performed on a DELL XPS 9550 laptop running Ubuntu 18.04 and Docker. CPU: Intel(R) Core(TM) i7-6700HQ

Reproducing the test

There are 2 test files:

  • test_with_safe/index.php: loads Composer autoloader with Safe
  • test_without_safe/index.php: loads Composer autoloader without Safe

Both test files are only loading Composer autoloader (with and without Safe), then echoing "foo".

For each file, you need to install the Composer dependencies:

cd test_with_safe
composer install
cd ..
cd test_without_safe
composer install
cd ..

A docker-compose.yml file is provided to start a PHP 7.2 environment with Blackfire enabled.

To start the environment, simply type:

BLACKFIRE_SERVER_ID=[xyz] BLACKFIRE_SERVER_TOKEN=[abc] docker-compose up

You can now browse to http://localhost:8888/test_with_safe and http://localhost:8888/test_without_safe and profile it using the Blackfire companion