Why does this code go so slowly?

Blitz3D Forums/Blitz3D Programming/Why does this code go so slowly?

The forum is locked. These are the original blitzbasic.com forums, kept so they can still be read. No new topics, replies or edits can be made here. To join in, head over to the Blitz3D+ forums.

This is really puzzling me. My timing code is left in. Mostly it outputs 0 or 1 for the time elapsed, but every now and then I get an 11 or 12, which seems WAY too long for this simple bit of code. Any suggestions?

MS = MilliSecs()

    ; Increase delay counters for all removed clients
    For i = RN_DelayLoop To RN_DelayLoop + 500
      If H\Clients[i] < 0 Then H\Clients[i] = H\Clients[i] + 1
    Next
    RN_DelayLoop = RN_DelayLoop + 501
    If RN_DelayLoop >= RN_MaxClientID
      RN_DelayLoop = 0
    ElseIf RN_DelayLoop > RN_MaxClientID - 500
      RN_DelayLoop = RN_MaxClientID - 500
    EndIf

MS = MilliSecs() - MS
If MS > 2 Then DebugLog MS


EDIT: Something else that's weird. As you can see, the code is some network code (from a new version of RottNet as a matter of fact). When a run a client and join the server, this same bit of code starts taking 200 milliseconds! That's really ridiculous. I can see why running another program at the same time will slow my server program down, but 200 milliseconds for that simple bit of code is far too long.