What is HHMV?

HHMV is an open-source virtual machine designed for executing PHP and HACK programs. HHMV uses JIT compiler for better performance. It supports Hack, PHP 5 and major features of PHP 7.

Facebook started HHMV tool in 2008, for converting PHP code into C++ so it can be compiled and run on the web server with use of less server resource. Facebook developed the Hip Hop Virtual Machine (HHVM).

Comparison between PHP and HHVM

No doubt HHVM is better than PHP 5. its execution time is far better than PHP 5 But while we compare it with PHP 7 it fails. due to PHP 7 uses the standard PHP interpreter, free software that is available for anyone to use, to directly interpret and execute PHP code on the server. This generates HTML code, which is then sent to the client. The client then displays the desired content to the web user, while the Hip Hop Virtual Machine first converts PHP code into Hip Hop bytecode. This code is then translated into machine code and executed. Some optimization takes place during this translation, ironing out inefficiencies in PHP code with the aim of delivering faster performance.

Benchmark Testing

For Benchmark Testing i have written the following very simple example to compute the exicution time of php script, running both using PHP and HHMV.

	$time_start = microtime(true);

	$arr = array();
	for($i= 0; $i < 10000000; $i++){
		array_push($arr, $i);

	$time_end = microtime(true);
	$execution_time = ($time_end - $time_start);

	echo "\nTotal Execution Time:\t ".$execution_time." Secs\n";

While execute the above code I found these results.

#Running with PHP 7
root@vishal:/var/www/html/hhvm# php index.php 
Total Execution Time:	 0.792 Secs
#Running with HHMV
root@vishal:/var/www/html/hhvm# hhvm index.php 
Total Execution Time:	 1.345 Secs
#Running with PHP 5
root@4a3d82b619f4:/var/www/html/hhvm# php index.php 
Total Execution Time:	 9.657 Secs

Leave a Reply

Your email address will not be published. Required fields are marked *