performance measurements

Each table row shows performance measurements for this Hack program with a particular command-line input value N.

 N  CPU secs Elapsed secs Memory KB Code B ≈ CPU Load
50,0000.300.28159,772787  29% 25% 36% 89%
500,0001.461.3461,820787  40% 87% 48% 48%
5,000,00013.1711.20267,120787  49% 76% 71% 51%

Read the ↓ make, command line, and program output logs to see how this program was run.

Read regex-dna benchmark to see what this program should do.

 notes

HipHop VM 3.0.0-dev (rel)
Compiler: heads/master-0-g7fe20173f182c6f8363c3f1752da50aa16c674df
Repo schema: daaf94930cc75e7b0cb2b11779a1be66280a5b6c

 regex-dna Hack program source code

<?hh
/* The Computer Language Benchmarks Game
   http://benchmarksgame.alioth.debian.org/

   contributed by Danny Sauer
   modified by Josh Goldfoot
   modified by Sergey Khripunov
   modified by Craig Russell
   PHP as HHVM/Hack by Isaac Gouy
*/

$tok = ftok(__FILE__, chr(time() & 255));
$queue = msg_get_queue($tok);

$variants = array(
    'agggtaaa|tttaccct',
    '[cgt]gggtaaa|tttaccc[acg]',
    'a[act]ggtaaa|tttacc[agt]t',
    'ag[act]gtaaa|tttac[agt]ct',
    'agg[act]taaa|ttta[agt]cct',
    'aggg[acg]aaa|ttt[cgt]ccct',
    'agggt[cgt]aa|tt[acg]accct',
    'agggta[cgt]a|t[acg]taccct',
    'agggtaa[cgt]|[acg]ttaccct',
);

// IUB replacement parallel arrays
$IUB = array(); $IUBnew = array();
$IUB[]='/B/S';     $IUBnew[]='(c|g|t)';
$IUB[]='/D/S';     $IUBnew[]='(a|g|t)';
$IUB[]='/H/S';     $IUBnew[]='(a|c|t)';
$IUB[]='/K/S';     $IUBnew[]='(g|t)';
$IUB[]='/M/S';     $IUBnew[]='(a|c)';
$IUB[]='/N/S';     $IUBnew[]='(a|c|g|t)';
$IUB[]='/R/S';     $IUBnew[]='(a|g)';
$IUB[]='/S/S';     $IUBnew[]='(c|g)';
$IUB[]='/V/S';     $IUBnew[]='(a|c|g)';
$IUB[]='/W/S';     $IUBnew[]='(a|t)';
$IUB[]='/Y/S';     $IUBnew[]='(c|t)';


// read in file
$contents = file_get_contents('php://stdin');
$initialLength = strlen($contents);

// remove things
$contents = preg_replace('/^>.*$|\n/mS', '', $contents);
$codeLength = strlen($contents);

// do regexp counts
$messages = array_flip($variants);
$workers = $results = array();
foreach ($variants as $key => $regex){
   if($key == 0 || $key == 2 || $key == 4 || $key == 6) {
      $pid = pcntl_fork();
      if($pid) $workers[] = $pid;
   }
   if($pid && $key > 7) {
      $messages[$regex] =
         preg_match_all('/' . $regex . '/iS', $contents, $discard);
   }
   else if(!$pid) {
      $results[] = $regex . ',' . 
         preg_match_all('/' . $regex . '/iS', $contents, $discard);
      if($key == 1 || $key == 3 || $key == 5 || $key == 7) {
         msg_send($queue, 2, implode(';', $results), false, false, $errno);
         exit;
	  }
   }
}

// receive and output the counts
pcntl_wait($status);
foreach($workers as $worker) {
   msg_receive($queue, 2, $msgtype, 4096, $message, false);
   $message = explode(';', $message, 3);
   foreach($message as $line) {
      $tmp = explode(',', $line, 2);
      $messages[$tmp[0]] = $tmp[1];
   }
}
foreach($messages as $regex => $count) {
   echo $regex, ' ', $count, "\n";
}

// do replacements
$contents = preg_replace($IUB, $IUBnew, $contents);

echo "\n",
      $initialLength, "\n",
      $codeLength, "\n",
      strlen($contents), "\n";

 make, command-line, and program output logs

Sat, 29 Mar 2014 06:41:31 GMT

COMMAND LINE:
/usr/local/src/hhvmdev/hhvm/hphp/hhvm/hhvm  regexdna.hack 0 < regexdna-input5000000.txt

PROGRAM OUTPUT:
agggtaaa|tttaccct 356
[cgt]gggtaaa|tttaccc[acg] 1250
a[act]ggtaaa|tttacc[agt]t 4252
ag[act]gtaaa|tttac[agt]ct 2894
agg[act]taaa|ttta[agt]cct 5435
aggg[acg]aaa|ttt[cgt]ccct 1537
agggt[cgt]aa|tt[acg]accct 1431
agggta[cgt]a|t[acg]taccct 1608
agggtaa[cgt]|[acg]ttaccct 2178

50833411
50000000
66800214

Revised BSD license

  Home   Conclusions   License   Play