Например такой небольшой бенч и анонимная медленнее на треть.
<?php
function cmp($a, $b) {
if ($a == $b) {
return 0;
}
return ($a < $b) ? -1 : 1;
};
$count = 100000;
$time = microtime(true);
for ($i = 0; $i < $count; $i++) {
$arr = [9, 7, 1, 5, 7, 12, 3, 9, 2];
usort($arr, function ($a, $b) {
if ($a == $b) {
return 0;
}
return ($a < $b) ? -1 : 1;
});
}
$time = microtime(true) - $time;
echo "Time: {$time}</br>";
$time = microtime(true);
for ($i = 0; $i < $count; $i++) {
$arr = [9, 7, 1, 5, 7, 12, 3, 9, 2];
usort($arr, 'cmp');
}
$time = microtime(true) - $time;
echo "Time: {$time}</br>";