Mantis - Quercus
Viewing Issue Advanced Details
3297 major always 01-26-09 14:06 01-29-09 14:42
koreth  
ferg  
normal  
closed 4.0.0  
fixed  
none    
none 4.0.0  
0003297: hash_hmac() is slow
<?php
$message = str_repeat('x', 1000);
$key = base64_decode("NMvhzq3jlze/4WlyuRXQ5w==");
$hash_key = base64_decode("CdMQm0q6JeUgalXRwQQZ1h/8WQA7fJh1OuY0xuZooxQ=");
$start = microtime(true);
for ($idx=0; $idx < 10000; $idx++) {
  $hash_val = hash_hmac('md5', $message, $hash_key, true);
}
print microtime(true) - $start;

This reports a run time of about 75ms under Zend PHP and about 610ms under Quercus in compiled mode (after repeated reloads to make sure the JVM has properly compiled everything.)

Notes
(0003786)
ferg   
01-29-09 14:42   
With the improved performance, Quercus is still slower (by 2x on my system). The time is mostly spent inside the crypto routines. This may be a case where Java is just slower than C for highly numerical calculations.