Skip to content

Commit

Permalink
Perform conversions from microsecond to second correctly (#507)
Browse files Browse the repository at this point in the history
* Perform conversions from microsecond to second correctly

* Whatever

---------

Co-authored-by: Sundaram Ananthanarayanan <sananthanarayanan@netflix.com>
  • Loading branch information
sundargates and sundargates committed Aug 1, 2023
1 parent f9a3261 commit d0251c4
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,8 @@ private void handleV1(Usage.UsageBuilder resourceUsageBuilder) throws IOExceptio
private void handleV2(Usage.UsageBuilder resourceUsageBuilder) throws IOException {
Map<String, Long> cpuStats = cgroup.getStats("", "cpu.stat");
resourceUsageBuilder
.cpusUserTimeSecs(cpuStats.getOrDefault("user_usec", 0L) / 1000.0)
.cpusSystemTimeSecs(cpuStats.getOrDefault("system_usec", 0L) / 1000.0);
.cpusUserTimeSecs(cpuStats.getOrDefault("user_usec", 0L) / 1000_000.0)
.cpusSystemTimeSecs(cpuStats.getOrDefault("system_usec", 0L) / 1000_000.0);

List<Long> metrics = cgroup.getMetrics("", "cpu.max");
if (metrics.size() != 2) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ public void testCgroupsV2() throws IOException {
process.getUsage(usageBuilder);
final Usage usage = usageBuilder.build();
assertEquals(2L, (long) usage.getCpusLimit());
assertEquals(4231313L, (long) usage.getCpusUserTimeSecs());
assertEquals(1277084L, (long) usage.getCpusSystemTimeSecs());
assertEquals(4231L, (long) usage.getCpusUserTimeSecs());
assertEquals(1277L, (long) usage.getCpusSystemTimeSecs());
}
}

0 comments on commit d0251c4

Please sign in to comment.