Skip to content

Commit

Permalink
Fixes the failing test
Browse files Browse the repository at this point in the history
Signed-off-by: Gagan Juneja <[email protected]>
  • Loading branch information
Gagan Juneja committed Jul 23, 2024
1 parent 1cb5c43 commit b137a47
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions src/main/java/org/opensearch/performanceanalyzer/util/Utils.java
Original file line number Diff line number Diff line change
Expand Up @@ -114,14 +114,16 @@ public static HashMap<ShardId, IndexShard> getShards() {

public static double calculateCPUUtilization(
int numProcessors, long totalOperationTime, long cpuUsageTime, double cpuShareFactor) {
LOG.debug("numProcessors {}", numProcessors);
LOG.debug("cpuShareFactor {}", cpuShareFactor);
LOG.debug("totalCpuTime {}", cpuUsageTime);
LOG.debug("totalOperationTime {}", totalOperationTime);
LOG.debug("CPUUtilization calculation - numProcessors {}", numProcessors);
LOG.debug("CPUUtilization calculation - cpuShareFactor {}", cpuShareFactor);
LOG.debug("CPUUtilization calculation - totalCpuTime {}", cpuUsageTime);
LOG.debug("CPUUtilization calculation - totalOperationTime {}", totalOperationTime);
if (totalOperationTime == 0l || cpuUsageTime == 0l || numProcessors == 0) {
return 0.0d;
}
double totalAvailableCPUTime = Double.valueOf(totalOperationTime * numProcessors);
return cpuShareFactor * (cpuUsageTime / totalAvailableCPUTime);
double cpuUtil = cpuShareFactor * (cpuUsageTime / totalAvailableCPUTime);
LOG.debug("CPUUtilization calculation - cpuUtil {}", cpuUtil);
return cpuUtil;
}
}

0 comments on commit b137a47

Please sign in to comment.