php arr1 array arr2 array for 10000 arr1 rand arr2 arr1 function ss v1

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
<?php
$arr1 = array();
$arr2 = array();
for($i=0;$i<10000;$i++) {
$arr1[$i] = rand();
$arr2[$i] = $arr1[$i];
}
function ss($v1, $v2) {
return $v1 > $v2;
}
function rss($v1, $v2) {
return !ss($v1, $v2);
}
$st = microtime(TRUE);
usort($arr1, 'ss');
$arr1 = array_reverse($arr1);
echo microtime(TRUE) - $st;
echo PHP_EOL;
$st = microtime(TRUE);
usort($arr1, 'rss');
echo microtime(TRUE) - $st;