Moein Hosseini
Moein Hosseini

Reputation: 4383

binary code of php (compiling php)

As you know php code doesn't compile to run,they are only script. but I heard somewhere if I compile it and make it as binary code,it can be so faster and reduce pressure on server. I Google a lot to do it,but I can't find a way to do it. how can I do it?

Upvotes: 4

Views: 3768

Answers (4)

Mob
Mob

Reputation: 11098

You probably read of Facebook's Hip Hop

HipHop was created by Facebook to save resources on its servers. It is being distributed with its over 300,000 lines of source code written in C++ and C as free software under the terms of version 3.01 of the PHP License.

This guy did a benchmark. Milliseconds for the 2nd and 3rd columns

Test name                PHP         HipHop            Ratio
n-body              754.474136     360.381707        209,35%
fannkuch-redux      3545.183693    1360.819455       260,52%
fasta               138.252463     55.924453         247,21%
spectral-norm       238.810613     93.717688         254,81%
mandelbrot          1532.191153    569.224470        269,17%
binary-trees (16)   37.286621      11.450954         325,62%
binary-trees (20)   1020.273547    249.907754        408,26%

Upvotes: 3

erlando
erlando

Reputation: 6756

Use a php accelerator. APC is widely used.

Upvotes: 2

webbiedave
webbiedave

Reputation: 48897

PHP compiles scripts into bytecodes, which can be cached, greatly speeding performance. Check out APC.

Here's a list of other accelerators:

http://en.wikipedia.org/wiki/List_of_PHP_accelerators

If you're looking to compile to native code, you can check out solutions like HipHop, which transforms PHP source into C++ and then compiles it with g++.

Upvotes: 7

Patrick Desjardins
Patrick Desjardins

Reputation: 140773

HipHop is a “source code transformer” designed to reduce CPU and memory usage by transforming your PHP code into C++ code.

Upvotes: 3

Related Questions