Re: [Discussion] Reflection-based constructor autowiring (scope clarification)
| From: | Marco Pivetta | Date: | Tue, 30 Dec 2025 18:41:24 +0000 |
| Subject: | Re: [Discussion] Reflection-based constructor autowiring (scope clarification) | ||
| References: | 1 2 3 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-129725@lists.php.net to get a copy of this message | ||
Hey Zoli,
On Tue, 30 Dec 2025 at 08:17, ANDRÁS Zoltán Gyárfás <azolee@gmail.com>
wrote:
> If you have any guidance on what you would consider a representative
> benchmark or a meaningful performance threshold for “worth moving into
> core”, I’d appreciate it.
>
In the grand majority of cases where autowiring is meaningful (at least for
PHP), you care about a "cold start" of the application (although that's
changing with ReactPHP/FrankenPHP/Roadrunner/etc.).
You may design a PHPBench or Hyperfine test that:
* starts a PHP process, autowires something, shuts down. Hyperfine helps a
lot here.
* repeats the above, but within a warm process (classes already loaded,
tight loop repeating the operation). PHPBench is a bit more precise here.
You probably care about these cases:
* zero-arguments constructor
* simple concrete class references
* default constructor arguments
* resolvers
* autowiring of a complex multi-level structure
In all the above cases, you probably care about the usage with autowiring
API vs the usage via direct instantiation, so you can see the exact
overhead.
Marco Pivetta
https://mastodon.social/@ocramius
https://ocramius.github.io/