Difference between revisions of "Lag check"

From Scriptwiki
Jump to: navigation, search
m (minor tweak)
m (Category. Added my own as well.)
 
Line 1: Line 1:
Here is a simple example of how to measure the response time from the IRC server.
+
Two simple scripts to check your lag with the 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.
 
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.
 +
 +
==Script 1==
  
 
  ; First we create an alias lagcheck, that sends out a "PING :lag <ticks>" to the server.
 
  ; First we create an alias lagcheck, that sends out a "PING :lag <ticks>" to the server.
Line 17: Line 19:
 
   }
 
   }
 
  }
 
  }
 +
 +
==Script 2==
 +
 +
;Create alias that will notice us with [[$ticks]]
 +
[[alias]] lagcheck {
 +
  ; Tells the user we are checking his lag with whichever server he typed it on
 +
  [[echo]] -atg Checking ping with [[$server]] [[DollarPlus|$+]] ...
 +
  ; Set a variable to the time we ran this command
 +
  [[set]] -u300 %ping. $+ $ticks $ticks
 +
  ; Notice ourself
 +
  .[[notice]] [[$me]] ping $ticks
 +
}
 +
; Receive our notice
 +
[[On notice|on ^*:NOTICE]]:ping &:?: {
 +
  ; make sure this notice is our script
 +
  if $nick == $me && %ping. [ $+ [ $2 ] ] {
 +
    ; keep us from seeing our notice
 +
  [[haltdef]]
 +
    ; calculate our lag with the server
 +
    echo -atg Current ping with $server $+ : [[$calc]]($ticks - $2) miliseconds.
 +
    ; cleanup
 +
    [[unset]] %ping. $+ $2
 +
  }
 +
}
 +
  
 
Put this in remote (alt+r), and use /lagcheck to check the response time from the IRC server.
 
Put this in remote (alt+r), and use /lagcheck to check the response time from the IRC server.
Line 23: Line 50:
  
 
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.
 +
 +
[[Category:Script Archive]]

Latest revision as of 00:42, 2 October 2008

Two simple scripts to check your lag with the 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.

Script 1

; 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
  }
}

Script 2

;Create alias that will notice us with $ticks
alias lagcheck {
  ; Tells the user we are checking his lag with whichever server he typed it on
  echo -atg Checking ping with $server $+ ...
  ; Set a variable to the time we ran this command
  set -u300 %ping. $+ $ticks $ticks
  ; Notice ourself
  .notice $me ping $ticks
}
; Receive our notice
on ^*:NOTICE:ping &:?: {
  ; make sure this notice is our script
  if $nick == $me && %ping. [ $+ [ $2 ] ] {
   ; keep us from seeing our notice
  haltdef
    ; calculate our lag with the server
    echo -atg Current ping with $server $+ : $calc($ticks - $2) miliseconds.
    ; cleanup 
   unset %ping. $+ $2
  }
}


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.