
- < ? php
- echo 'Hello HipHop' ;
- ? >
$ time ./hphp index.php --keep-tempdir = 1 --log = 3 running hphp ... creating temporary directory / tmp / hphp_71TLF1 ... parsing inputs ... parsing ./index.php ... parsing inputs took 0'00 "(6 ms) (null) pre-optimizing ... pre-optimizing took 0'00 "(0 ms) (null) inferring types ... inferring types took 0'00 "(0 ms) (null) post-optimizing ... post-optimizing took 0'00 "(0 ms) (null) creating CPP files ... creating CPP files took 0'00 "(213 ms) (null) compiling and linking CPP files ... compiling and linking CPP files took 1'30 "(90733 ms) (null) running executable / tmp / hphp_71TLF1 / program - file index.php ... Hello HipHopall files saved in / tmp / hphp_71TLF1 ... running hphp took 1'31 "(91747 ms) (null) real 1m31.791s user 1m21.157s sys 0m6.500s
$ ls -l / tmp / hphp_71TLF1 / total 25152 -rw-r - r-- 1 20673 Feb 21 12:19 CMakeCache.txt drwxr-xr-x 6 4096 Feb 21 12:21 CMakeFiles -rw-r - r-- 1 1558 Feb 21 12:19 cmake_install.cmake -rw-r - r-- 1 2518 Feb 21 12:19 CMakeLists.txt -rw-r - r-- 1 18343 Feb 21 12:19 Makefile drwxr-xr-x 2 4096 Feb 21 12:19 php -rwxr-xr-x 1 25653366 Feb 21 12:21 program drwxr-xr-x 2 4096 Feb 21 12:19 sys $ ls -l / tmp / hphp_71TLF1 / php total 12 -rw-r - r-- 1 783 Feb 21 12:19 index.cpp -rw-r - r-- 1 415 Feb 21 12:19 index.fw.h -rw-r - r-- 1 475 Feb 21 12:19 index.h
- #include <php / index.h>
- #include <cpp / ext / ext.h>
- namespace HPHP {
- ////////////////////////////////////////////////// /////////////////////////////
- / * preface starts * /
- / * preface finishes * /
- Variant pm_php $ index_php ( bool incOnce / * = false * / , LVariableTable * variables / * = NULL * / ) {
- FUNCTION_INJECTION ( run_init :: index . Php ) ;
- {
- DECLARE_GLOBAL_VARIABLES ( g ) ;
- bool & alreadyRun = g - > run_pm_php $ index_php ;
- if ( alreadyRun ) { if ( incOnce ) return true ; }
- else alreadyRun = true ;
- if ( ! variables ) variables = g ;
- }
- DECLARE_GLOBAL_VARIABLES ( g ) ;
- LVariableTable * gVariables __attribute__ ( ( __unused__ ) ) = get_variable_table ( ) ;
- print ( "Hello HipHop" ) ;
- return true ;
- } / * function * /
- ////////////////////////////////////////////////// /////////////////////////////
- }
$ time php test.php answer: 39 real 0m32.308s user 0m32.258s sys 0m0.012s $ time / tmp / hphp_4C67mv / program - file test.php answer: 39 real 1m6.683s user 1m6.376s sys 0m0.168s $ g ++ test.cpp $ time ./a.out answer: 39 real 0m1.758s user 0m1.744s sys 0m0.000s
<? php
for ($ i = 0; $ i <1000; $ i ++)
echo var_dump ($ _ SERVER);
?> $ ./program -m server -p 8080
$ ab -n 1000 -c 5 http://127.0.0.1:8080/test.php
Concurrency Level: 5
Time taken for tests: 67.019 seconds
Complete requests: 1000
Failed requests: 0
Write errors: 0
Total transferred: 1166084000 bytes
HTML transferred: 1166000000 bytes
Requests per second: 14.92 [# / sec] (mean)
Time per request: 335.096 [ms] (mean)
Time per request: 67.019 [ms] (mean, across all concurrent requests)
Transfer rate: 16991.44 [Kbytes / sec] received
Connection Times (ms)
min mean [+/- sd] median max
Connect: 0 0 0.1 0 2
Processing: 124 335 56.5 340 477
Waiting: 120 329 56.2 335 467
Total: 124 335 56.5 341 477 $ ab -n 1000 -c 5 http://127.0.0.1:80/test.php
...
Concurrency Level: 5
Time taken for tests: 27.180 seconds
Complete requests: 1000
Failed requests: 0
Write errors: 0
Total transferred: 1139183000 bytes
HTML transferred: 1139000000 bytes
Requests per second: 36.79 [# / sec] (mean)
Time per request: 135.901 [ms] (mean)
Time per request: 27.180 [ms] (mean, across all concurrent requests)
Transfer rate: 40929.90 [Kbytes / sec] received
Connection Times (ms)
min mean [+/- sd] median max
Connect: 0 0 0.5 0 11
Processing: 52,136 32.2 137,216
Waiting: 0 3 1.5 3 17
Total: 52 136 32.2 137 216
| Language | Time | Relative Speed |
|---|---|---|
| C gcc-4.4.3 | 0.05 seconds | 1.00 x |
| Hiphop | 0.18 seconds | 3.60 x |
| Python 2.51 | 2.35 seconds | 47.00 x |
| PHP 5.2.12 | 3.08 seconds | 61.60 x |
Source: https://habr.com/ru/post/85092/
All Articles