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
1011.3211.3275,628440  100% 1% 0% 1%
11148.17148.2172,300440  91% 10% 0% 1%
122,144.152,144.7676,304440  37% 28% 0% 35%

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

Read fannkuch-redux benchmark to see what this program should do.

 notes

HipHop VM 3.4.1 (rel)
Compiler: tags/HHVM-3.4.1-0-g5b66f110ebe9bafccecd8946d391b0f895dc107a
Repo schema: bf1db525c412a46f0b4b68c5a5bed52f64183008
Extension API: 20140829

 fannkuch-redux Hack #2 program source code

<?hh 
/* The Computer Language Benchmarks Game
   http://benchmarksgame.alioth.debian.org/
   
   contributed by Isaac Gouy, transliterated from Mike Pall's Lua program 
   further optimization by Oleksii Prudkyi
   PHP as HHVM/Hack by Isaac Gouy
*/

$n = (int)$argv[1];
$s = range(0, $n - 1);
$i = $maxflips = $checksum = 0; 
$sign = 1; 
$m = $n - 1;
$p = $q = $s;
do {
   // Copy and flip.
   $q0 = $p[0];
   if ($q0 != 0){
      $q = $p;
      $flips = 1;
      do { 
         $qq = $q[$q0]; 
         if ($qq == 0){
            $checksum += $sign*$flips;
            if ($flips > $maxflips) $maxflips = $flips;
            break; 
         } 
         $q[$q0] = $q0; 
         if ($q0 >= 3){
            $i = 1; $j = $q0 - 1;
            do { 
               $t = $q[$i]; 
               $q[$i] = $q[$j]; 
               $q[$j] = $t; 
               ++$i;
               --$j;
            } while ($i < $j); 
         }
         $q0 = $qq; 
         ++$flips;
      } while (true); 
   }
   // Permute.
   if ($sign == 1){
      $t = $p[1]; $p[1] = $p[0]; $p[0] = $t; $sign = -1; // Rotate 0<-1.
   } else { 
      $t = $p[1]; $p[1] = $p[2]; $p[2] = $t; $sign = 1;  // Rotate 1<-2.
      for($i=2; $i<$n; ){ 
         $sx = &$s[$i];
         if ($sx != 0)
         {
            --$sx; 
            break; 
         }
         if ($i == $m){
            printf("%d\nPfannkuchen(%d) = %d\n", $checksum, $n, $maxflips);// Out of permutations.
            return;
         }
         $s[$i] = $i;
         // Rotate 0<-...<-i+1.
         $t = $p[0]; 
         for($j=0; $j<=$i; ){ $p[$j++] = $p[$j]; } 
         ++$i;
         $p[$i] = $t;
      }
   }
} while (true);

 make, command-line, and program output logs

Fri, 19 Dec 2014 20:39:26 GMT

MAKE:
/usr/bin/hh_client
No errors!
0.02s to complete and log all make actions

COMMAND LINE:
/usr/bin/hhvm  fannkuchredux.hack-2.hack 12

PROGRAM OUTPUT:
3968050
Pfannkuchen(12) = 65

Revised BSD license

  Home   Conclusions   License   Play