I guess you already saw a short note Latency Numbers Every Programmer Should Know. I wanted to check how well Nette performs with its magic properties on Nette\Object
.
You can see the testing code below together with raw output on my machine.
It show how much time in seconds it took to execute one million iterations of a particular action, thus it is also time in microseconds of one such call. You should compare it to null test, which execute empty iterations.
Compared to a native getter of public property:
- method call is cca 4x slower
- magic getter is cca 15x slower
- magic getter in form isSomething() is cca 25x slower
In a real app this does not cause any issue. I tested it on an our eshop where it added only cca 1ms to a page load, which was almost nothing to a total page load time.
PHP: 5.3.13
null: 0.18924808502197
direct: 0.29860186576843
method: 0.68159699440002
magic: 5.2286150455475
magic2: 5.9565918445587