Skip to content

Instantly share code, notes, and snippets.

@bobbydeveaux
Created March 13, 2014 21:26
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bobbydeveaux/9537318 to your computer and use it in GitHub Desktop.
Save bobbydeveaux/9537318 to your computer and use it in GitHub Desktop.
PHP Bubble Sort
<?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();
@bobbydeveaux
Copy link
Author

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment