Compiling them without modification fails, but after removing a couple of tests and correcting errors, they can be easily launched.
It comes about such results for 5 runs (PHP 7.4 with OpCache and without XDebug):
|micro_bench — PHP 7.4||micro_bench — KPHP||bench — PHP 7.4||bench — KPHP|
|avg PHP 7.4||avg KPHP||avg PHP 7.4||avg KPHP|
According to these benchmarks, KPHP is found to be 5–7 times faster.
Although they are quite synthetic, this is pretty much similar to other measurements.
Consider the dedicated page. It also shows a 4–10 times breakthrough.
The main idea to pick from that text: as far as your project grows, using KPHP becomes more reliable.
This can be called “zero-cost abstractions” — not zero of course, but considerably smaller than in PHP:
But still: the only adequate way to compare performance is to take a real working high-loaded site.
If we measure PHP 7.2 version and KPHP-compiled on the same server, for a random account, we get
vk.com/feed — PHP: 10.1 sec, KPHP: 0.95 sec
vk.com/im — PHP: 1.25 sec, KPHP: 0.46 sec
vk.com/ads — PHP: 0.73 sec, KPHP: 0.20 sec
In general, for VK.com we have from 3 to 10 times average profit. Pretty much to suffer a bit, right?
Having a goal to optimize particular places, you can achieve even better results.
VK.com has some heavy pieces of business logic, which perform ML calculations in real-time. Such areas were specially optimized, fulfilling all KPHP potential.
Measuring that isolated pieces of code shows tremendous superiority of strict typing:
neural networks with huge matrices — PHP: ~8 sec, KPHP: 0.24 sec
deep decision trees with tons of branches — PHP: ~5 sec, KPHP: 0.14 sec
But. It’s a bad idea to state “KPHP is always faster than PHP”.
It may be wrong. If PHP code just calls strpos() or parse_url(), KPHP would have almost no benefits, as they are just PHP standard functions implemented in C. But the more business logic is PHP-implemented, the faster KPHP becomes in comparison — especially if you write PHP code keeping types in mind.
You can speed up your code — if you really ought to.