Here's my variation. Enhances the existing ping command and (unless I screwed up) produces screen output exactly as the normal ping function does.

ping {
if ($1 != -m) /ctcp $$1 ping
else {
.raw PRIVMSG $$2 : $+ $chr(1) $+ PING $ticks msec $+ $chr(1)
echo -itlbfmrc ctcp -> $chr(91) $+ $$2 $+ $chr(93) PING
halt
}
}

on *:CTCPREPLY:PING * msec:{
echo -esitlbfmrc ctcp $+([,$nick) PING reply]: $calc(($ticks - $2)/1000) $+ secs
haltdef
}

/ping Nick = normal ping
/ping -m Nick = milisecond ping