Skip to content

Commit

Permalink
improve toString in ExprCPUUsage
Browse files Browse the repository at this point in the history
  • Loading branch information
EquipableMC committed Dec 20, 2024
1 parent 6854880 commit 3d566ae
Showing 1 changed file with 8 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -79,13 +79,14 @@ public Class<? extends Double> getReturnType() {

@Override
public String toString(@Nullable Event event, boolean debug) {
return switch (matchedPattern) {
case 0 -> (useProcess ? "process" : "system") + " CPU usage over the last 10 seconds";
case 1 -> (useProcess ? "process" : "system") + " CPU usage over the last 1 minute";
case 2 -> (useProcess ? "process" : "system") + " CPU usage over the last 15 minutes";
case 3 -> (useProcess ? "process" : "system") + " CPU usage for all available periods";
default -> throw new IllegalStateException("Invalid CPU usage expression");
};
return "the " + (useProcess ? "process" : "system") + " over the last" +
switch (matchedPattern) {
case 0 -> "10 seconds";
case 1 -> "1 minute";
case 2 -> "15 minutes";
case 3 -> "all available periods";
default -> throw new IllegalStateException("Invalid CPU usage expression");
};
}

}

0 comments on commit 3d566ae

Please sign in to comment.