rfc:autoload_classmap

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
rfc:autoload_classmap [2021/03/15 17:28] marandallrfc:autoload_classmap [2021/04/06 05:32] (current) marandall
Line 2: Line 2:
   * Version: 1   * Version: 1
   * Date: 2021-03-15   * Date: 2021-03-15
-  * Author: Mark Randall, mrandall@php.net+  * Author: Mark Randall, marandall@php.net
   * Status: Under Discussion   * Status: Under Discussion
   * Target: 8.1   * Target: 8.1
Line 31: Line 31:
   * Always check the classmap first if it is set.    * Always check the classmap first if it is set. 
   * (If Found) Trigger a TypeError if the key's associated value is not a string.   * (If Found) Trigger a TypeError if the key's associated value is not a string.
-  * (If Found) Use the REQUIRE_ONCE mechanism. +  * (If Found) Use the REQUIRE mechanism. 
   * (If Found) Trigger an Error if the relevant class is not defined after including the file specified in the classmap.   * (If Found) Trigger an Error if the relevant class is not defined after including the file specified in the classmap.
  
 If the classmap is not set, or the class name cannot be found within the classmap, the autoloader will continue to perform its traditional behaviour of iterating over the functions specified by spl_autoload_register.  If the classmap is not set, or the class name cannot be found within the classmap, the autoloader will continue to perform its traditional behaviour of iterating over the functions specified by spl_autoload_register. 
 +
 +===== Performance =====
 +
 +Testing suggests that autoloading through an internal classmap delivers around 5% performance increase vs a userland function call (e.g. composer). 
 +
 +This is 5% of the cost of the autoloading, and not the execution as a whole. Testing was performed by creating 50,000 empty classes each in an individual file, and then autoloading every one of them in a loop. Amount of classes was purely to help reduce noise.
 +
 +Average for internal classmap was 0.295 vs 0.313 for spl_autoload_register representing 5.9% difference (in autoload performance only).
 +
  
 ===== Proposed PHP Version(s) ===== ===== Proposed PHP Version(s) =====
rfc/autoload_classmap.1615829320.txt.gz · Last modified: 2021/03/15 17:28 by marandall