10000 ); } $aValues = range(0, $aOpts['i'], 1); shuffle($aValues); $aTest = array(); foreach ($aValues as $iValue) { $aTest[md5($iValue)]['price'] = $iValue; } $aClone = $aTest; $fStart = microtime(true); usort($aClone, '_usort'); $fUsort = (microtime(true) - $fStart); print_r('usort: ' . $fUsort . PHP_EOL); $aClone = $aTest; $fStart = microtime(true); _testSort($aClone); $fTestSort = (microtime(true) - $fStart); print_r('_testSort: ' . $fTestSort . PHP_EOL); print_r('Diff: ' . round($fUsort / $fTestSort, 2) . PHP_EOL); function _usort($a, $b) { return $a['price'] > $b['price'] ? 1 : (($a['price'] == $b['price']) ? 0 : -1); } function _testSort(&$aSort) { $aReturn = $aKeyValue = array(); foreach ($aSort as $mKey => $aItem) { $aKeyValue[$mKey] = $aItem['price']; } asort($aKeyValue); $aKeys = array_keys($aKeyValue); foreach ($aKeys as $mKey) { $aReturn[] = $aSort[$mKey]; } $aSort = $aReturn; unset($aKeys, $aKeyValue, $aReturn); }