请求统计表格添加合计行
This commit is contained in:
parent
d31382ec2a
commit
54b30d4215
|
@ -1,12 +1,10 @@
|
|||
package io.metersphere.report;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.opencsv.bean.CsvToBean;
|
||||
import com.opencsv.bean.CsvToBeanBuilder;
|
||||
import com.opencsv.bean.HeaderColumnNameMappingStrategy;
|
||||
import io.metersphere.report.base.Metric;
|
||||
import io.metersphere.report.base.RequestStatistics;
|
||||
|
||||
import java.io.Reader;
|
||||
import java.io.StringReader;
|
||||
import java.text.DecimalFormat;
|
||||
|
@ -76,10 +74,9 @@ public class JtlResolver {
|
|||
}
|
||||
});
|
||||
|
||||
Integer tp90 = elapsedList.size()*9/10;
|
||||
Integer tp90 = elapsedList.size()*90/100;
|
||||
Integer tp95 = elapsedList.size()*95/100;
|
||||
Integer tp99 = elapsedList.size()*99/100;
|
||||
|
||||
Long l = Long.valueOf(timestampList.get(index-1)) - Long.valueOf(timestampList.get(0));
|
||||
|
||||
RequestStatistics requestStatistics = new RequestStatistics();
|
||||
|
@ -101,6 +98,11 @@ public class JtlResolver {
|
|||
requestStatistics.setMin(elapsedList.get(0)+"");
|
||||
requestStatistics.setMax(elapsedList.get(index-1)+"");
|
||||
requestStatistics.setErrors(String.format("%.2f",failSize*100.0/index)+"%");
|
||||
requestStatistics.setKo(failSize);
|
||||
/**
|
||||
* #Samples/(取最大值(ts+t)-取最小值(ts))*1000
|
||||
*/
|
||||
// todo Avg Bandwidth(KBytes/s)
|
||||
requestStatistics.setKbPerSec(String.format("%.2f",totalBytes*1.0/1024/(l*1.0/1000)));
|
||||
requestStatisticsList.add(requestStatistics);
|
||||
}
|
||||
|
|
|
@ -35,6 +35,9 @@ public class RequestStatistics {
|
|||
/**错误率 Error Percentage */
|
||||
private String errors;
|
||||
|
||||
/**错误个数*/
|
||||
private Integer ko;
|
||||
|
||||
public String getRequestLabel() {
|
||||
return requestLabel;
|
||||
}
|
||||
|
@ -122,4 +125,12 @@ public class RequestStatistics {
|
|||
public void setErrors(String errors) {
|
||||
this.errors = errors;
|
||||
}
|
||||
|
||||
public Integer getKo() {
|
||||
return ko;
|
||||
}
|
||||
|
||||
public void setKo(Integer ko) {
|
||||
this.ko = ko;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -6,6 +6,7 @@
|
|||
border
|
||||
style="width: 100%"
|
||||
show-summary
|
||||
:summary-method="getSummaries"
|
||||
:default-sort = "{prop: 'samples', order: 'descending'}"
|
||||
>
|
||||
<el-table-column label="Requests" fixed width="450" align="center">
|
||||
|
@ -27,7 +28,7 @@
|
|||
prop="errors"
|
||||
label="Error%"
|
||||
align="center"
|
||||
fixed="right"/>
|
||||
/>
|
||||
</el-table-column>
|
||||
|
||||
<el-table-column label="Response Times(ms)" align="center">
|
||||
|
@ -86,6 +87,26 @@
|
|||
this.$get("/report/content/" + this.id, res => {
|
||||
this.tableData = res.data;
|
||||
})
|
||||
},
|
||||
getSummaries (param) {
|
||||
const { data } = param
|
||||
const sums = []
|
||||
let allSamples = data.reduce(function (total, currentValue) {
|
||||
return total + currentValue.samples;
|
||||
}, 0);
|
||||
let failSize = data.reduce(function (total, currentValue) {
|
||||
return total + currentValue.ko;
|
||||
}, 0);
|
||||
let allAverageTime = data.reduce(function (total, currentValue) {
|
||||
return total + parseFloat(currentValue.average) * currentValue.samples;
|
||||
}, 0);
|
||||
sums[0] = 'Total'
|
||||
sums[1] = allSamples;
|
||||
sums[2] = (Math.round(failSize / allSamples * 10000) / 100) + '%';
|
||||
sums[3] = (allAverageTime / allSamples).toFixed(2);
|
||||
sums[4] = Math.min.apply(Math, data.map(function(o) {return parseFloat(o.min)}));
|
||||
sums[5] = Math.max.apply(Math, data.map(function(o) {return parseFloat(o.max)}));
|
||||
return sums
|
||||
}
|
||||
},
|
||||
created() {
|
||||
|
@ -94,11 +115,13 @@
|
|||
props: ['id'],
|
||||
watch: {
|
||||
'$route'(to) {
|
||||
let reportId = to.path.split('/')[4];
|
||||
if(reportId){
|
||||
this.$get("/report/content/" + reportId, res => {
|
||||
this.tableData = res.data;
|
||||
})
|
||||
if (to.name === "perReportView") {
|
||||
let reportId = to.path.split('/')[4];
|
||||
if(reportId){
|
||||
this.$get("/report/content/" + reportId, res => {
|
||||
this.tableData = res.data;
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue