Skip to content

Commit

Permalink
Switch to nanotime for statistics
Browse files Browse the repository at this point in the history
  • Loading branch information
dries-c committed Mar 4, 2024
1 parent ce00c07 commit c2171ed
Showing 1 changed file with 2 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ private void onBedrockBatch(@NonNull BedrockBatchWrapper batch) {
wrapper.release(); // release
batch.modify();

this.latency = (System.currentTimeMillis() - this.lastPingTimestamp) / 2;
this.latency = (System.nanoTime() - this.lastPingTimestamp) / 2;
this.broadcastPing();
}
}
Expand Down Expand Up @@ -181,7 +181,7 @@ public void collectStats() {

sendPacket(packet);

this.lastPingTimestamp = System.currentTimeMillis();
this.lastPingTimestamp = System.nanoTime();
} else if (this.channel instanceof EpollSocketChannel epollChannel) {
this.latency = epollChannel.tcpInfo().rtt() / 2;
this.broadcastPing();
Expand Down

0 comments on commit c2171ed

Please sign in to comment.