While loops are slow, file reads are slower, both together are excessively slower.

To prove just how slow while loops are:
Code:
alias benchNoLoop {
  !var %y = 5
  !var %ticks = $ticks
  !dec %y
  !dec %y
  !dec %y
  !dec %y
  !dec %y
  !inc %benchNoLoop $calc($ticks - %ticks)
}
alias benchLoop {
  !var %y = 5
  !var %ticks = $ticks
  !while (%y) {
    !dec %y
  }
  !inc %benchLoop $calc($ticks - %ticks)
}

alias TestLoop {
  set -u0 %benchNoLoop 0
  set -u0 %benchLoop 0
  var %x = $1
  while (%x) {
    .benchLoop
    .benchNoLoop
    dec %x
  }
  echo -a -
  echo -a Test: $1
  echo -a NoLp: %benchNoLoop $+ ms ( $+ $round($calc(%benchNoLoop / $1),3) per test)
  echo -a Loop: %benchLoop $+ ms ( $+ $round($calc(%benchLoop / $1),3) per test)
  echo -a Diff: $calc(%benchLoop - %benchNoLoop) $+ ms ( $+ $round($calc(%benchLoop / %benchNoLoop),3) times faster)
}


Using a clean mIRC that is offline with no scripts but the above loaded, issuing /testloop 1000000 produces:
Code:
Test: 1000000
NoLp: 35469ms (0.035 per test)
Loop: 72987ms (0.073 per test)
Diff: 37518ms (2.058 times faster)
that's twice the amount of time to issue the same number of commands from within a loop verses not looping at all

Last edited by FroggieDaFrog; 17/04/15 03:20 PM.