Difference between revisions of "Lag check"

From Scriptwiki
Jump to: navigation, search
(initial version)
 
m (minor tweak)
Line 9: Line 9:
 
   
 
   
 
  ; Second we create an on PONG event, to catch the reply and halt the default output.
 
  ; Second we create an on PONG event, to catch the reply and halt the default output.
  ; We then calculate the difference between the value of ticks that is returned
+
  ; The difference between $ticks and the returned value is the response time in milliseconds.
  ; and the current value of $ticks and echo the result to the status window.
+
  ; Echo this to the status window and halt the default output.
 
  on ^*:PONG:{
 
  on ^*:PONG:{
 
   if ($2 == lag) && ($3 isnum) {
 
   if ($2 == lag) && ($3 isnum) {
Line 17: Line 17:
 
   }
 
   }
 
  }
 
  }
 +
 +
Put this in remote (alt+r), and use /lagcheck to check the response time from the IRC server.
  
 
You could also save the result to a variable and use this info in any other place, and run a timer to refresh this value at an interval.
 
You could also save the result to a variable and use this info in any other place, and run a timer to refresh this value at an interval.
  
 
If you use a bouncer, the bouncer may be responding to the PING request instead of the IRC server, or even return the wrong reply.
 
If you use a bouncer, the bouncer may be responding to the PING request instead of the IRC server, or even return the wrong reply.

Revision as of 17:48, 14 February 2008

Here is a simple example of how to measure the response time from the IRC server.

Response time being the time it takes to travel from your client to the IRC server, be processed by the IRC server, and send back to your client.

; First we create an alias lagcheck, that sends out a "PING :lag <ticks>" to the server.
alias lagcheck {
  .quote PING :lag $ticks
}

; Second we create an on PONG event, to catch the reply and halt the default output.
; The difference between $ticks and the returned value is the response time in milliseconds.
; Echo this to the status window and halt the default output.
on ^*:PONG:{
  if ($2 == lag) && ($3 isnum) {
    echo -s Response time: $calc($ticks - $3) ms
    haltdef
  }
}

Put this in remote (alt+r), and use /lagcheck to check the response time from the IRC server.

You could also save the result to a variable and use this info in any other place, and run a timer to refresh this value at an interval.

If you use a bouncer, the bouncer may be responding to the PING request instead of the IRC server, or even return the wrong reply.