That's because, imo, you didn't benchmark these two aliases correctly. Without explaining why I think my benchmarks are more accurate (even though simpler in structure), here's what I used:
alias max1 return $gettok($sorttok($1-,32,nr),1,32)
alias max2 {
var %i = $0, %a = $1
while %i {
if ($eval($ $+ %i,2) > %a) %a = $ifmatch
dec %i
}
return %a
}
alias bcmark {
var %i = $1, %t = $ticks
while %i { $2- | dec %i }
echo -s $2 time: $calc($ticks - %t)
}
I then ran /bcmark 5000 max1 <list> and /bcmark 5000 max2 <same list> several times (at random intervals). The results are quite different that yours. At the first few runs, <list> was in both cases this:
34 34 68 29 09 34 563 653 354356 3563 3 35356 366 36 36 36 3452 653 236
The difference was very noticeable. A typical value pair from the various times I executed the commands is this:
max1 time: 1094
max2 time: 8922
The I tried several times the same commands, with this input:
1 2
A typical result was this:
max1 time: 437
max2 time: 1453
You can see two things from this:
1) max1 is always faster than max2
2) with different input lengths, max1 gives similar results while the results of max2 differ a lot. This confirms my thoughts that, since both aliases are made in mirc script, you can assume with acceptable accuracy that max1 is constant-time (it only calls an identifier once) while max2 is linear-time (N, as it loops through %i).