Skip to content

Commit

Permalink
细节优化
Browse files Browse the repository at this point in the history
  • Loading branch information
aoliaoaoaojiao committed Oct 13, 2024
1 parent f6323ae commit 7771b91
Showing 1 changed file with 33 additions and 7 deletions.
40 changes: 33 additions & 7 deletions src/components/AndroidPerfChart.vue
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,14 @@ const props = defineProps({
procThread: Array,
});
function getTimeStr(timestamp) {
const now = new Date(timestamp);
const hour = now.getHours().toString().padStart(2, '0');
const minute = now.getMinutes().toString().padStart(2, '0');
const second = now.getSeconds().toString().padStart(2, '0');
return `${hour}:${minute}:${second}`;
}
const printSingleCpu = () => {
let chart = echarts.getInstanceByDom(
document.getElementById(
Expand Down Expand Up @@ -127,7 +135,7 @@ let sysCpuData = {
}
const pushSysCpuData = (obj) => {
sysCpuData.xAxisData.push(new Date(obj.cpu.timeStamp))
sysCpuData.xAxisData.push(getTimeStr(obj.cpu.timeStamp))
if (obj.cpu) {
for (const i in obj.cpu) {
if (i !== 'timeStamp') {
Expand Down Expand Up @@ -239,7 +247,7 @@ let sysMemData = {
}
const pushSysMemData = (obj) => {
sysMemData.xAxisData.push(new Date(obj.timeStamp))
sysMemData.xAxisData.push(getTimeStr(obj.timeStamp))
sysMemData.memBuffersData.push(obj.memBuffers)
sysMemData.memCached.push(obj.memCached)
sysMemData.memCached.push(obj.memFree)
Expand Down Expand Up @@ -273,6 +281,12 @@ const printMem = () => {
},
tooltip: {
trigger: 'axis',
position(pos, params, dom, rect, size) {
const obj = {top: 60};
obj[['left', 'right'][+(pos[0] < size.viewSize[0] / 2)]] = 5;
return obj;
},
valueFormatter: (value) => `${value}`,
},
grid: {top: '30%', left: '20%'},
toolbox: {
Expand Down Expand Up @@ -359,7 +373,7 @@ let procFPSData = {
seriesData: []
}
const pushProcFPSData = (obj) => {
procFPSData.xAxisData.push(new Date(obj.timeStamp))
procFPSData.xAxisData.push(getTimeStr(obj.timeStamp))
procFPSData.seriesData.push(obj.fps)
}
const printProcFps = () => {
Expand Down Expand Up @@ -425,9 +439,11 @@ let procThreadData = {
}
const pushProcThreadData = (obj) => {
console.log(obj)
procThreadData.xAxisData.push(new Date(obj.timestamp))
procThreadData.xAxisData.push(getTimeStr(obj.timeStamp))
procThreadData.seriesData.push(obj.threadCount)
}
const printProcThread = () => {
let chart = echarts.getInstanceByDom(
document.getElementById(
Expand Down Expand Up @@ -495,7 +511,7 @@ const pushSysNetworkData = (obj) => {
let isAddTime = true;
for (const i in obj) {
if (isAddTime) {
sysNetworkData.xAxisData.push(new Date(obj[i].timeStamp));
sysNetworkData.xAxisData.push(getTimeStr(obj[i].timeStamp));
isAddTime = false;
}
Expand Down Expand Up @@ -552,6 +568,16 @@ const printNetwork = () => {
},
tooltip: {
trigger: 'axis',
position(pos, params, dom, rect, size) {
const obj = {top: 60};
obj[['left', 'right'][+(pos[0] < size.viewSize[0] / 2)]] = 5;
return obj;
},
valueFormatter: (value) => `${value}`,
},
legend: {
top: '8%',
data: sysNetworkData.legendData,
},
grid: {top: '20%', left: '18%'},
toolbox: {
Expand Down Expand Up @@ -582,7 +608,7 @@ let procCpuData = {
seriesData: []
}
const pushProcCpuData = (obj) => {
procCpuData.xAxisData.push(new Date(obj.timeStamp))
procCpuData.xAxisData.push(getTimeStr(obj.timeStamp))
procCpuData.seriesData.push(obj.cpuUtilization)
}
const printPerfCpu = () => {
Expand Down Expand Up @@ -653,7 +679,7 @@ let procMemData = {
vmData: []
}
const pushProcMemData = (obj) => {
procMemData.xAxisData.push(new Date(obj.timeStamp))
procMemData.xAxisData.push(getTimeStr(obj.timeStamp))
procMemData.phyData.push(obj.phyRSS)
procMemData.vmData.push(obj.vmRSS)
procMemData.pssData.push(obj.totalPSS)
Expand Down

0 comments on commit 7771b91

Please sign in to comment.