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