Part 6 - nbody benchmark
Finally, I got the nbody benchmark from Debian benchmark games to run correctly! The result:
Language | Time to complete |
---|---|
PHP 7.0.0 | 186 sec |
subsetphp | 13 sec |
Java | 6 sec |
This makes subsetphp around 14 times faster than PHP 7 on my local machine.
Some caveats:
- The compiler is just a prototype - adding features might speed up or slow down the benchmark.
- This is a number-crunching benchmark, PHP was not made for that purpose - so who cares?
- Still cool!
If anyone is interested you can view the PHP code here.
Some comments about the code:
- Why no functions? Because I haven’t added support to infer types like
array<object>
. - You might see the if-statement before some for-loops - the for-statement has a bug, will fix soon.
- The code is copied from the Java version.
This successful benchmark will mark version 0.1. Next version will include:
- The binary tree benchmark, testing GC performance
- Infer arrays passed as arguments to functions, possibly using static “duck-typing” (inspired by the OCaml object system)
- Escape analysis, enforcing allocation on stack where possible
- Other stuff
Wish you a nice week!
Olle