3
0
mirror of https://github.com/pragma-/pbot.git synced 2024-11-20 02:49:49 +01:00

LagChecker: Minor polish to cmd_lackcheck()

This commit is contained in:
Pragmatic Software 2021-06-05 13:37:49 -07:00
parent 8057e929ff
commit f500f4b354

View File

@ -78,21 +78,26 @@ sub cmd_lagcheck {
my $lag_total = $elapsed;
my $len = @{$self->{lag_history}};
my $lagstring = "";
my $comma = "";
my @entries;
foreach my $entry (@{$self->{lag_history}}) {
my ($send_time, $lag_result) = @$entry;
$lag_total += $lag_result;
my $ago = concise ago(gettimeofday - $send_time);
$lagstring .= $comma . "[$ago] " . sprintf "%.1f ms", $lag_result;
$comma = "; ";
push @entries, "[$ago] " . sprintf "%.1f ms", $lag_result;
}
$lagstring .= $comma . "[waiting for pong] $elapsed";
push @entries, "[waiting for pong] $elapsed";
my $lagstring = join '; ', @entries;
my $average = $lag_total / ($len + 1);
$lagstring .= "; average: " . sprintf "%.1f ms", $average;
return $lagstring;
}