1

I read somewhere that classmap autoloading is faster than PSR-0/PSR-4. Of course for development process is better to use PSR-0/PSR-4. We can easily create a classmap via composer with -o param from PSR-0/PSR-4.

My question: is classmap autoloading really faster? With all vendors I have almost 3000 classes in my project. It means autoload_classmap.php file with 3000 lines (and an array with 3000 items). Is it still faster then autoloading using PSR-0/PSR-4 in production?

tommy
  • 388
  • 2
  • 14
  • Can anyone reliably answer this question without creating a classmap autoloader with 3000 entries and benchmarking it vs. some "average" scenario where a "reasonable" (but arbitrary) number of classes are loaded with PSR-0 or PSR-4? – Jon Aug 25 '14 at 21:32
  • Classmap lookups are by definition faster. Their drawback is usually the memory consumption. OTOH you already scattered your class definitions over 3000 files (due to PSR-x) instead of conjoining dependent ones. So it's unlikely the concrete autoloader will have a measurable impact. – mario Aug 25 '14 at 21:38

1 Answers1

0

Please see my answer here: Why use a PSR-0 or PSR-4 autoload in composer if classmap is actually faster?

No need to duplicate everything.

Community
  • 1
  • 1
Sven
  • 69,403
  • 10
  • 107
  • 109