This commit is contained in:
chenjianxing 2020-04-26 16:56:08 +08:00
commit 4b96010d3a
2 changed files with 52 additions and 21 deletions

View File

@ -84,7 +84,7 @@ public class ReportService {
LoadTestReportResultExample example = new LoadTestReportResultExample(); LoadTestReportResultExample example = new LoadTestReportResultExample();
example.createCriteria().andReportIdEqualTo(id).andReportKeyEqualTo(reportKey.name()); example.createCriteria().andReportIdEqualTo(id).andReportKeyEqualTo(reportKey.name());
List<LoadTestReportResult> loadTestReportResults = loadTestReportResultMapper.selectByExampleWithBLOBs(example); List<LoadTestReportResult> loadTestReportResults = loadTestReportResultMapper.selectByExampleWithBLOBs(example);
if (loadTestReportResults.size() != 1) { if (loadTestReportResults.size() == 0) {
MSException.throwException("get report result error."); MSException.throwException("get report result error.");
} }
return loadTestReportResults.get(0).getReportValue(); return loadTestReportResults.get(0).getReportValue();

View File

@ -96,10 +96,16 @@
}) })
this.$get("/performance/report/content/load_chart/" + this.id, res => { this.$get("/performance/report/content/load_chart/" + this.id, res => {
let data = res.data; let data = res.data;
let userList = data.filter(m => m.groupName === "users").map(m => m.yAxis); let yAxisList = data.filter(m => m.yAxis2 === -1).map(m => m.yAxis);
let hitsList = data.filter(m => m.groupName === "hits").map(m => m.yAxis); let yAxis2List = data.filter(m => m.yAxis === -1).map(m => m.yAxis2);
let userMax = this._getChartMax(userList); let yAxisListMax = this._getChartMax(yAxisList);
let hitsMax = this._getChartMax(hitsList); let yAxis2ListMax = this._getChartMax(yAxis2List);
let yAxisIndex0List = data.filter(m => m.yAxis2 === -1).map(m => m.groupName);
yAxisIndex0List = this._unique(yAxisIndex0List);
let yAxisIndex1List = data.filter(m => m.yAxis === -1).map(m => m.groupName);
yAxisIndex1List = this._unique(yAxisIndex1List);
let loadOption = { let loadOption = {
title: { title: {
text: 'Load', text: 'Load',
@ -119,17 +125,17 @@
name: 'User', name: 'User',
type: 'value', type: 'value',
min: 0, min: 0,
max: userMax, max: yAxisListMax,
splitNumber: 5, splitNumber: 5,
interval: userMax / 5 interval: yAxisListMax / 5
}, },
{ {
name: 'Hits/s', name: 'Hits/s',
type: 'value', type: 'value',
splitNumber: 5, splitNumber: 5,
min: 0, min: 0,
max: hitsMax, max: yAxis2ListMax,
interval: hitsMax / 5 interval: yAxis2ListMax / 5
} }
], ],
series: [] series: []
@ -152,15 +158,27 @@
} }
] ]
} }
yAxisIndex0List.forEach(item => {
setting["series"].splice(0, 0, {name: item, yAxisIndex: '0'})
})
yAxisIndex1List.forEach(item => {
setting["series"].splice(0, 0, {name: item, yAxisIndex: '1'})
})
this.loadOption = this.generateOption(loadOption, data, setting); this.loadOption = this.generateOption(loadOption, data, setting);
}) })
this.$get("/performance/report/content/res_chart/" + this.id, res => { this.$get("/performance/report/content/res_chart/" + this.id, res => {
let data = res.data; let data = res.data;
let userList = data.filter(m => m.groupName === "users").map(m => m.yAxis); let yAxisList = data.filter(m => m.yAxis2 === -1).map(m => m.yAxis);
let responseTimeList = data.filter(m => m.groupName != "users").map(m => m.yAxis); let yAxis2List = data.filter(m => m.yAxis === -1).map(m => m.yAxis2);
let responseGroupNameList = data.filter(m => m.groupName != "users").map(m => m.groupName); let yAxisListMax = this._getChartMax(yAxisList);
let userMax = this._getChartMax(userList); let yAxis2ListMax = this._getChartMax(yAxis2List);
let resMax = this._getChartMax(responseTimeList);
let yAxisIndex0List = data.filter(m => m.yAxis2 === -1).map(m => m.groupName);
yAxisIndex0List = this._unique(yAxisIndex0List);
let yAxisIndex1List = data.filter(m => m.yAxis === -1).map(m => m.groupName);
yAxisIndex1List = this._unique(yAxisIndex1List);
let resOption = { let resOption = {
title: { title: {
text: 'Response Time', text: 'Response Time',
@ -197,15 +215,15 @@
name: 'User', name: 'User',
type: 'value', type: 'value',
min: 0, min: 0,
max: userMax, max: yAxisListMax,
interval: userMax / 5 interval: yAxisListMax / 5
}, },
{ {
name: 'Response Time', name: 'Response Time',
type: 'value', type: 'value',
min: 0, min: 0,
max: resMax, max: yAxis2ListMax,
interval: resMax / 5 interval: yAxis2ListMax / 5
} }
], ],
series: [] series: []
@ -218,9 +236,15 @@
} }
] ]
} }
responseGroupNameList.forEach(item => {
yAxisIndex0List.forEach(item => {
setting["series"].splice(0, 0, {name: item, yAxisIndex: '0'})
})
yAxisIndex1List.forEach(item => {
setting["series"].splice(0, 0, {name: item, yAxisIndex: '1'}) setting["series"].splice(0, 0, {name: item, yAxisIndex: '1'})
}) })
this.resOption = this.generateOption(resOption, data, setting); this.resOption = this.generateOption(resOption, data, setting);
}) })
}, },
@ -245,7 +269,11 @@
legend.push(name) legend.push(name)
series[name] = [] series[name] = []
} }
series[name].splice(xAxis.indexOf(item.xAxis), 0, [item.xAxis, item.yAxis.toFixed(2)]); if (item.yAxis === -1) {
series[name].splice(xAxis.indexOf(item.xAxis), 0, [item.xAxis, item.yAxis2.toFixed(2)]);
} else {
series[name].splice(xAxis.indexOf(item.xAxis), 0, [item.xAxis, item.yAxis.toFixed(2)]);
}
}) })
this.$set(option.legend, "data", legend); this.$set(option.legend, "data", legend);
this.$set(option.legend, "type", "scroll"); this.$set(option.legend, "type", "scroll");
@ -276,7 +304,10 @@
_getChartMax(arr) { _getChartMax(arr) {
const max = Math.max(...arr); const max = Math.max(...arr);
return Math.ceil(max / 4.5) * 5; return Math.ceil(max / 4.5) * 5;
} },
_unique(arr){
return Array.from(new Set(arr));
}
}, },
watch: { watch: {
status() { status() {