Commit d95fcc62 authored by wanli's avatar wanli

🐞 fix: 更新资源监视器前端

parent e1bc1a28
...@@ -369,55 +369,42 @@ function byteToKiloByte(obj) { ...@@ -369,55 +369,42 @@ function byteToKiloByte(obj) {
} }
function calculate(obj, name, list) { function calculate(obj, name, list) {
result[name] = [{ title: "最新值" }, { title: "最旧值" }, { title: "最大值" }, { title: "最小值" }, { title: "平均值" }]; // new old max min avg
Object.keys(obj).forEach((k) => { Object.keys(obj).forEach((k) => {
result[name + "First"][k] = 0; result[name][0][k] = 0;
result[name + "Last"][k] = 0; result[name][1][k] = 0;
let first = 0, result[name][2][k] = 0;
last = Date.now(); result[name][3][k] = 0;
result[name][4][k] = 0;
let first = 0, last = Date.now();
const t = list.map((item) => { const t = list.map((item) => {
if (item.ts > first) { if (item.ts > first) {
first = item.ts; first = item.ts;
result[name + "First"][k] = item[k]; result[name][0][k] = item[k];
} }
if (item.ts < last) { if (item.ts < last) {
last = item.ts; last = item.ts;
result[name + "Last"][k] = item[k]; result[name][1][k] = item[k];
} }
return item[k]; return item[k];
}); });
result[name + "Max"][k] = Math.max.apply(null, t); result[name][2][k] = Math.max.apply(null, t);
result[name + "Min"][k] = Math.min.apply(null, t); result[name][3][k] = Math.min.apply(null, t);
result[name + "Avg"][k] = Math.ceil( result[name][4][k] = Math.ceil(t.reduce((prev, curr) => prev + curr) / t.length);
t.reduce((prev, curr) => prev + curr) / t.length
);
}); });
} }
function resetResult() { function resetResult() {
return { return {
evmMax: {}, evm: [],
evmMin: {}, lvgl: [],
evmAvg: {}, system: [],
evmFirst: {},
evmLast: {},
lvglMax: {},
lvglMin: {},
lvglAvg: {},
lvglFirst: {},
lvglLast: {},
systemMax: {},
systemMin: {},
systemAvg: {},
systemFirst: {},
systemLast: {},
systemImg: null,
evmImg: null, evmImg: null,
lvglImg: null, lvglImg: null,
systemImg: null,
imageList: [], imageList: [],
}; };
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment