From f84b14540112d0cdc668d70870dac5bdfc56122e Mon Sep 17 00:00:00 2001 From: Michael Lange Date: Fri, 14 Sep 2018 10:21:01 -0700 Subject: [PATCH] Use the appropriate methods and types in the stat trackers --- .../utils/classes/allocation-stats-tracker.js | 20 +++++++++++-------- ui/app/utils/classes/node-stats-tracker.js | 4 ++-- 2 files changed, 14 insertions(+), 10 deletions(-) diff --git a/ui/app/utils/classes/allocation-stats-tracker.js b/ui/app/utils/classes/allocation-stats-tracker.js index d0a4422df..5053ccea4 100644 --- a/ui/app/utils/classes/allocation-stats-tracker.js +++ b/ui/app/utils/classes/allocation-stats-tracker.js @@ -19,16 +19,18 @@ const AllocationStatsTracker = EmberObject.extend(AbstractStatsTracker, { }), append(frame) { + const timestamp = new Date(Math.floor(frame.Timestamp / 1000000)); + const cpuUsed = Math.floor(frame.ResourceUsage.CpuStats.TotalTicks) || 0; - this.get('cpu').push({ - timestamp: frame.Timestamp, + this.get('cpu').pushObject({ + timestamp, used: cpuUsed, percent: percent(cpuUsed, this.get('reservedCPU')), }); const memoryUsed = frame.ResourceUsage.MemoryStats.RSS; - this.get('memory').push({ - timestamp: frame.Timestamp, + this.get('memory').pushObject({ + timestamp, used: memoryUsed, percent: percent(memoryUsed / 1024 / 1024, this.get('reservedMemory')), }); @@ -41,16 +43,18 @@ const AllocationStatsTracker = EmberObject.extend(AbstractStatsTracker, { // allocation, don't attempt to append data for the task. if (!stats) continue; + const frameTimestamp = new Date(Math.floor(taskFrame.Timestamp / 1000000)); + const taskCpuUsed = Math.floor(taskFrame.ResourceUsage.CpuStats.TotalTicks) || 0; - stats.cpu.push({ - timestamp: taskFrame.Timestamp, + stats.cpu.pushObject({ + timestamp: frameTimestamp, used: taskCpuUsed, percent: percent(taskCpuUsed, stats.reservedCPU), }); const taskMemoryUsed = taskFrame.ResourceUsage.MemoryStats.RSS; - stats.memory.push({ - timestamp: taskFrame.Timestamp, + stats.memory.pushObject({ + timestamp: frameTimestamp, used: taskMemoryUsed, percent: percent(taskMemoryUsed / 1024 / 1024, stats.reservedMemory), }); diff --git a/ui/app/utils/classes/node-stats-tracker.js b/ui/app/utils/classes/node-stats-tracker.js index ca6122d2f..3b2702d23 100644 --- a/ui/app/utils/classes/node-stats-tracker.js +++ b/ui/app/utils/classes/node-stats-tracker.js @@ -22,14 +22,14 @@ const NodeStatsTracker = EmberObject.extend(AbstractStatsTracker, { const timestamp = new Date(Math.floor(frame.Timestamp / 1000000)); const cpuUsed = Math.floor(frame.CPUTicksConsumed) || 0; - this.get('cpu').addObject({ + this.get('cpu').pushObject({ timestamp, used: cpuUsed, percent: percent(cpuUsed, this.get('reservedCPU')), }); const memoryUsed = frame.Memory.Used; - this.get('memory').addObject({ + this.get('memory').pushObject({ timestamp, used: memoryUsed, percent: percent(memoryUsed / 1024 / 1024, this.get('reservedMemory')),