コード例 #1
0
 public static function main()
 {
     $sampleSize = 10000;
     $iterations = 1;
     $x = 0;
     $time = 0;
     $a = array_fill(0, $sampleSize, NULL);
     for ($i = 0; $i < $sampleSize; $i++) {
         $a[$i] = rand(0, 100);
     }
     $bse = new AlgorithmTest();
     // Go through all iterations
     while ($x < $iterations) {
         $time = $time + $bse->quickSort($a, 0, $sampleSize - 1);
         $x++;
     }
     echo "Average microtime: " . $time / $iterations;
 }
コード例 #2
0
 public static function main()
 {
     $sampleSize = 10000000;
     $find = 10000000;
     $iterations = 10;
     $x = 0;
     $time = 0;
     $a = array_fill(0, $sampleSize, NULL);
     for ($i = 0; $i < $sampleSize; $i++) {
         $a[$i] = $i + 1;
     }
     $bse = new AlgorithmTest();
     // Go through all iterations
     while ($x < $iterations) {
         $time = $time + $bse->search($a, $find);
         $x++;
     }
     echo "Average microtime: " . $time / $iterations;
 }