Skip to content

Commit

Permalink
Reworked TPS command to show averages over different times
Browse files Browse the repository at this point in the history
  • Loading branch information
DustinRepo committed Mar 15, 2022
1 parent 1608f29 commit 0d056b4
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 2 deletions.
16 changes: 15 additions & 1 deletion src/me/dustin/chatbot/command/impl/CommandTPS.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,20 @@ public CommandTPS() {

@Override
public void run(String str, UUID sender) {
sendChat(String.format("Current tps: %.1f", ChatBot.getClientConnection().getTpsHelper().getAverageTPS()));
double instant = getClientConnection().getTpsHelper().getTPS(2);
String s = String.format("TPS: Instant: %.2f", instant);
if (getClientConnection().getTpsHelper().reportSize() >= 15) {
double sec15 = getClientConnection().getTpsHelper().getTPS(15);
s += String.format(" | 15 seconds: %.2f", sec15);
}
if (getClientConnection().getTpsHelper().reportSize() >= 30) {
double sec30 = getClientConnection().getTpsHelper().getTPS(30);
s += String.format(" | 30 seconds: %.2f", sec30);
}
if (getClientConnection().getTpsHelper().reportSize() >= 60) {
double sec60 = getClientConnection().getTpsHelper().getTPS(60);
s += String.format(" | 60 seconds: %.2f", sec60);
}
sendChat(s);
}
}
6 changes: 5 additions & 1 deletion src/me/dustin/chatbot/helper/TPSHelper.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,17 @@ public double getAverageTPS() {
return getTPS(reports.size());
}

public int reportSize() {
return reports.size();
}

public void clear() {
reports.clear();
}

public void worldTime() {
reports.add(System.currentTimeMillis());
while (reports.size() > 15) {
while (reports.size() > 60) {
reports.remove(0);
}
}
Expand Down

0 comments on commit 0d056b4

Please sign in to comment.