Created
March 13, 2014 21:26
-
-
Save bobbydeveaux/9537318 to your computer and use it in GitHub Desktop.
PHP Bubble Sort
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
function main() { | |
for ($c=0;$c<1000000;$c++) { | |
bubble(); | |
} | |
} | |
function bubble() { | |
$array = array(3,4,1,3,5,1,92,2,4124,424,52,12); | |
for ($i=0;$i<count($array);$i++) { | |
for ($y=0;$y<count($array)-1;$y++) { | |
if ($array[$y+1] < $array[$y]) { | |
$t = $array[$y]; | |
$array[$y] = $array[$y+1]; | |
$array[$y+1] = $t; | |
} | |
} | |
} | |
} | |
main(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
HHVM
$ time hhvm -v Eval.Jit=true hhvm.php
real 0m2.622s
real 0m2.657s
real 0m2.615s
real 0m2.662s
real 0m2.599s
PHP 5.5 OPcache
$ time php hhvm.php
real 0m30.421s
real 0m27.603s
real 0m27.695s
real 0m27.336s
real 0m27.706s