mirror of
https://github.com/OkaeriPoland/okaeri-timings.git
synced 2026-01-18 03:28:20 +01:00
Fix cpu history not being relative to the previous entry
This commit is contained in:
@@ -47,7 +47,7 @@ export default {
|
|||||||
type: Object
|
type: Object
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
data: function() {
|
data: function () {
|
||||||
|
|
||||||
const metrics = ['cpu/user', 'cpu/nice', 'cpu/system', 'cpu/idle', 'cpu/iowait', 'cpu/irq', 'cpu/softirq', 'cpu/steal', 'cpu/guest', 'cpu/guest_nice'];
|
const metrics = ['cpu/user', 'cpu/nice', 'cpu/system', 'cpu/idle', 'cpu/iowait', 'cpu/irq', 'cpu/softirq', 'cpu/steal', 'cpu/guest', 'cpu/guest_nice'];
|
||||||
const header = this.report.header;
|
const header = this.report.header;
|
||||||
@@ -59,11 +59,18 @@ export default {
|
|||||||
.map(row => row.reduce((a, b) => a + b, 0))
|
.map(row => row.reduce((a, b) => a + b, 0))
|
||||||
|
|
||||||
const series = metrics.map(metric => {
|
const series = metrics.map(metric => {
|
||||||
const index = header.indexOf(metric);
|
const headerIndex = header.indexOf(metric);
|
||||||
return {
|
const name = metric.replace('cpu/', '');
|
||||||
name: metric.replace('cpu/', ''),
|
const mData = data.map((entry, rowIndex) => {
|
||||||
data: data.map((entry, i) => [new Date(entry[timeIndex] * 1000), (entry[index] / cpuDataSums[i] * 100)])
|
let share = rowIndex > 0
|
||||||
}
|
? (entry[headerIndex] - data[rowIndex - 1][headerIndex]) / (cpuDataSums[rowIndex] - cpuDataSums[rowIndex - 1])
|
||||||
|
: entry[headerIndex] / cpuDataSums[rowIndex];
|
||||||
|
return [
|
||||||
|
new Date(entry[timeIndex] * 1000),
|
||||||
|
share * 100
|
||||||
|
];
|
||||||
|
});
|
||||||
|
return {name, data: mData}
|
||||||
});
|
});
|
||||||
|
|
||||||
return {
|
return {
|
||||||
|
|||||||
Reference in New Issue
Block a user