diff --git a/ui/app/utils/classes/allocation-stats-tracker.js b/ui/app/utils/classes/allocation-stats-tracker.js index 41959d1a0..5977f684f 100644 --- a/ui/app/utils/classes/allocation-stats-tracker.js +++ b/ui/app/utils/classes/allocation-stats-tracker.js @@ -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, @@ -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, diff --git a/ui/tests/unit/utils/allocation-stats-tracker-test.js b/ui/tests/unit/utils/allocation-stats-tracker-test.js index fb0108997..0126c39b4 100644 --- a/ui/tests/unit/utils/allocation-stats-tracker-test.js +++ b/ui/tests/unit/utils/allocation-stats-tracker-test.js @@ -54,6 +54,7 @@ module('Unit | Util | AllocationStatsTracker', function () { }, MemoryStats: { RSS: (step + 400) * 1024 * 1024, + Usage: (step + 400) * 1024 * 1024, }, }, Tasks: { @@ -64,6 +65,7 @@ module('Unit | Util | AllocationStatsTracker', function () { }, MemoryStats: { RSS: (step + 100) * 1024 * 1024, + Usage: (step + 100) * 1024 * 1024, }, }, Timestamp: refDate + step, @@ -75,6 +77,7 @@ module('Unit | Util | AllocationStatsTracker', function () { }, MemoryStats: { RSS: (step + 50) * 1024 * 1024, + Usage: (step + 50) * 1024 * 1024, }, }, Timestamp: refDate + step * 10, @@ -86,6 +89,7 @@ module('Unit | Util | AllocationStatsTracker', function () { }, MemoryStats: { RSS: (step + 51) * 1024 * 1024, + Usage: (step + 51) * 1024 * 1024, }, }, Timestamp: refDate + step * 100,