Skip to content

Commit

Permalink
Consolidate stats tracker consts, and add Usage to tracker test
Browse files Browse the repository at this point in the history
  • Loading branch information
philrenaud committed Aug 3, 2022
1 parent 85d9795 commit 642d5cc
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 12 deletions.
20 changes: 8 additions & 12 deletions ui/app/utils/classes/allocation-stats-tracker.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,12 +49,10 @@ class AllocationStatsTracker extends EmberObject.extend(AbstractStatsTracker) {
percent: percent(cpuUsed, this.reservedCPU),
});

let memoryUsed = 0;
if (frame.ResourceUsage.MemoryStats.Usage) {
memoryUsed = frame.ResourceUsage.MemoryStats.Usage;
} else {
memoryUsed = frame.ResourceUsage.MemoryStats.RSS;
}
const memoryUsed =
frame.ResourceUsage.MemoryStats.Usage ||
frame.ResourceUsage.MemoryStats.RSS ||
0;

this.memory.pushObject({
timestamp,
Expand Down Expand Up @@ -86,12 +84,10 @@ class AllocationStatsTracker extends EmberObject.extend(AbstractStatsTracker) {
percentStack: percentCpuTotal + aggregateCpu,
});

let taskMemoryUsed = 0;
if (frame.ResourceUsage.MemoryStats.Usage) {
taskMemoryUsed = frame.ResourceUsage.MemoryStats.Usage;
} else {
taskMemoryUsed = frame.ResourceUsage.MemoryStats.RSS;
}
const taskMemoryUsed =
frame.ResourceUsage.MemoryStats.Usage ||
frame.ResourceUsage.MemoryStats.RSS ||
0;

const percentMemoryTotal = percent(
taskMemoryUsed / 1024 / 1024,
Expand Down
4 changes: 4 additions & 0 deletions ui/tests/unit/utils/allocation-stats-tracker-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ module('Unit | Util | AllocationStatsTracker', function () {
},
MemoryStats: {
RSS: (step + 400) * 1024 * 1024,
Usage: (step + 400) * 1024 * 1024,
},
},
Tasks: {
Expand All @@ -64,6 +65,7 @@ module('Unit | Util | AllocationStatsTracker', function () {
},
MemoryStats: {
RSS: (step + 100) * 1024 * 1024,
Usage: (step + 100) * 1024 * 1024,
},
},
Timestamp: refDate + step,
Expand All @@ -75,6 +77,7 @@ module('Unit | Util | AllocationStatsTracker', function () {
},
MemoryStats: {
RSS: (step + 50) * 1024 * 1024,
Usage: (step + 50) * 1024 * 1024,
},
},
Timestamp: refDate + step * 10,
Expand All @@ -86,6 +89,7 @@ module('Unit | Util | AllocationStatsTracker', function () {
},
MemoryStats: {
RSS: (step + 51) * 1024 * 1024,
Usage: (step + 51) * 1024 * 1024,
},
},
Timestamp: refDate + step * 100,
Expand Down

0 comments on commit 642d5cc

Please sign in to comment.