alias speedtest1 {
var %cnt = 10000, %ticks = $ticks
while (%cnt) {
noop mode $chan +q $snicks $+ $crlf $+ mode $chan -q $snicks $+ $crlf $+ mode $chan +v $snicks
dec %cnt
}
echo -a (speedtest1): $calc(($ticks - %ticks) / 1000)
}
alias speedtest2 {
var %cnt = 10000, %ticks = $ticks, %chan = $chan, %snicks = $snicks
while (%cnt) {
noop mode %chan +q %snicks $+ $crlf $+ mode %chan -q %snicks $+ $crlf $+ mode %chan +v %snicks
dec %cnt
}
echo -a (speedtest2): $calc(($ticks - %ticks) / 1000)
}
alias speedtest {
var %cnt = 5
while (%cnt) {
speedtest1
speedtest2
linesep -a
dec %cnt
}
}
/speedtest
I get:
(speedtest1): 1.265
(speedtest2): 0.547
-
(speedtest1): 1.203
(speedtest2): 0.563
-
(speedtest1): 1.265
(speedtest2): 0.547
-
(speedtest1): 1.187
(speedtest2): 0.563
-
(speedtest1): 1.203
(speedtest2): 0.547
Seems that %vars are faster. That's when you're doing 10,000 loops though. When using them once the difference is going to be a couple of milliseconds at best.
Edit: in fact, it will be slower to use vars one time, because you're going to have to evaluate the identifier to set the variable, and then use the variable. It'll be quicker to use the identifier directly.