3 ms·
This is what I get locally: time php fib.php 42 23s time python3 fib.py 42 1m1s I suspect that you're doing something very wrong, like runnin
by nikic 5y ago
This is what I get locally:
time php fib.php 42
23s
time python3 fib.py 42
1m1s
I suspect that you're doing something very wrong, like running PHP with an active debugger or similar.
If we're talking in comparison to slow interpreted languages like Python, then function calls in PHP are not particularly expensive. Debuggers can make them quite expensive though.
Edit: Just to note, PHP's execution time drops to 4s with enabled JIT.
- dncornholio 5y agoI also get around 23s, PHP 7.4.5
- hnjobs238987204 5y agoLikely. I tried the benchmark and saw runtimes of over 5 minutes before realizing that XDebug was active and in develop mode. Adding `-d xdebug.mode=off` dropped it to 26s. That was with `opcache.jit` in the (default?) `tracing` mode. Turning it off didn't change the runtime, which is a bit puzzling. This is all with PHP8 on macOS, although I tried 8.1RC in docker and saw similar results. Something doesn't quite add up across everyone's results here, but the extremely slow result at the top of the thread is almost certainly a debugger slowing things down. Edit: I was missing `opcache.jit_buffer_size`, and saw the runtime drop to under ten seconds with that correctly configured.