4 ms·
PHP results: I was stupid enough to write some scientific code in PHP once so know how slow it can be - mostly around array access and manipulation. But if your
by theteapot 3y ago
PHP results: I was stupid enough to write some scientific code in PHP once so know how slow it can be - mostly around array access and manipulation. But if your going to try, use the HHVM interpreter. It's much faster and is a drop in replacement for the PHP interpreter. Hack (https://hacklang.org/ https://hacklang.org/) uses that under the hood by default.
- geek_at 3y agoAlso since PHP was built for web requests it builds The cache on the First run. would be interesting to see All languages of the benchmark with a second run
- habibur 3y agoI put the pure math codes in C extension of PHP. Building C extension for PHP is easier than most of the other high level languages. And then things get blazingly fast.
- brrrrrm 3y agodoesn't look that easy... zend_parse_parameters? pre-baked configure + make scripts? check out how a modern language deals with this stuff https://bun.sh/docs/api/ffi#usage https://bun.sh/docs/api/ffi#usage
- rafark 3y agoCheckout what? PHP also has support for FFI. Or am I missing something?
- EmberTwin 3y agoHHVM is not a drop-in replacement for a PHP interpreter. The semantics of Hack and PHP have diverged, typically in the direction of eliminating dynamic behavior from Hack that existed in PHP (examples: string -> function coercion, the PHP dual vector-hash-table array type, and non-throwing out-of-bounds array accesses are all gone from Hack). The semantics changes both simplify static analysis and make it easier to JIT fast code.
- Ayesh 3y agoThe state of PHP 8.3 and especially 8.4 is a lot better than HHVM. They have diverged quite a lot to a point that it's no longer a drop-in replacement. PHP added JIT in 8.0, and these math-heavy tasks can take advantage of it. It's not trivial to fine tine JIT configuration though. In PHP 8.4 (scheduled Nov 2024), there is a major upgrade to JIT as well.