删除无用代码
This commit is contained in:
parent
66b6a1a63b
commit
1c4b50e760
|
@ -3,8 +3,6 @@ package io.metersphere.commons.constants;
|
|||
public class RoleConstants {
|
||||
public final static String ADMIN = "admin";
|
||||
public final static String ORG_ADMIN = "org_admin";
|
||||
// 组织内其它角色
|
||||
public final static String ORG_OTHER = "org_other";
|
||||
public final static String TEST_VIEWER = "test_viewer";
|
||||
public final static String TEST_MANAGER = "test_manager";
|
||||
public final static String TEST_USER = "test_user";
|
||||
|
|
|
@ -4,7 +4,6 @@ import com.alibaba.fastjson.JSONObject;
|
|||
import com.opencsv.bean.CsvToBean;
|
||||
import com.opencsv.bean.CsvToBeanBuilder;
|
||||
import com.opencsv.bean.HeaderColumnNameMappingStrategy;
|
||||
import io.metersphere.commons.exception.MSException;
|
||||
import io.metersphere.report.base.*;
|
||||
import io.metersphere.report.dto.ErrorsTop5DTO;
|
||||
import io.metersphere.report.dto.RequestStatisticsDTO;
|
||||
|
@ -19,6 +18,8 @@ import java.util.stream.Collectors;
|
|||
|
||||
public class JtlResolver {
|
||||
|
||||
private static final Integer ERRORS_TOP_SIZE = 5;
|
||||
|
||||
private static List<Metric> resolver(String jtlString) {
|
||||
HeaderColumnNameMappingStrategy<Metric> ms = new HeaderColumnNameMappingStrategy<>();
|
||||
ms.setType(Metric.class);
|
||||
|
@ -37,59 +38,64 @@ public class JtlResolver {
|
|||
}
|
||||
|
||||
public static RequestStatisticsDTO getRequestStatistics(String jtlString){
|
||||
List<Metric> total = resolver(jtlString);
|
||||
Map<String, List<Metric>> map = total.stream().collect(Collectors.groupingBy(Metric::getLabel));
|
||||
List<Integer> allElapseTimeList = new ArrayList<>();
|
||||
List<RequestStatistics> requestStatisticsList = new ArrayList<>();
|
||||
Iterator<Map.Entry<String, List<Metric>>> iterator = map.entrySet().iterator();
|
||||
List<Integer> allelapse = new ArrayList<>();
|
||||
DecimalFormat df = new DecimalFormat("0.00");
|
||||
int totalAverage = 0;
|
||||
float allBytes = 0f;
|
||||
DecimalFormat decimalFormat = new DecimalFormat("0.00");
|
||||
|
||||
List<Metric> totalLines = resolver(jtlString);
|
||||
Map<String, List<Metric>> jtlLabelMap = totalLines.stream().collect(Collectors.groupingBy(Metric::getLabel));
|
||||
Iterator<Map.Entry<String, List<Metric>>> iterator = jtlLabelMap.entrySet().iterator();
|
||||
|
||||
int totalElapsedTime = 0;
|
||||
float totalBytes = 0f;
|
||||
|
||||
while (iterator.hasNext()) {
|
||||
Map.Entry<String, List<Metric>> entry = iterator.next();
|
||||
String label = entry.getKey();
|
||||
List<Metric> list = entry.getValue();
|
||||
int index=0;
|
||||
int sumElapsed=0;
|
||||
int failSize = 0;
|
||||
// 以list为单位 total bytes
|
||||
float totalBytes = 0f;
|
||||
List<Metric> metricList = entry.getValue();
|
||||
List<Integer> elapsedList = new ArrayList<>();
|
||||
for (int i = 0; i < list.size(); i++) {
|
||||
|
||||
int jtlSamplesSize = 0, oneLineElapsedTime = 0, failSize = 0;
|
||||
float oneLineBytes = 0f;
|
||||
|
||||
for (int i = 0; i < metricList.size(); i++) {
|
||||
try {
|
||||
Metric row = list.get(i);
|
||||
Metric row = metricList.get(i);
|
||||
String elapsed = row.getElapsed();
|
||||
sumElapsed += Integer.parseInt(elapsed);
|
||||
totalAverage += Integer.parseInt(elapsed);
|
||||
oneLineElapsedTime += Integer.parseInt(elapsed);
|
||||
totalElapsedTime += Integer.parseInt(elapsed);
|
||||
elapsedList.add(Integer.valueOf(elapsed));
|
||||
allelapse.add(Integer.valueOf(elapsed));
|
||||
String success = row.getSuccess();
|
||||
if (!"true".equals(success)){
|
||||
allElapseTimeList.add(Integer.valueOf(elapsed));
|
||||
|
||||
String isSuccess = row.getSuccess();
|
||||
if (!"true".equals(isSuccess)){
|
||||
failSize++;
|
||||
}
|
||||
String bytes = row.getBytes();
|
||||
oneLineBytes += Float.parseFloat(bytes);
|
||||
totalBytes += Float.parseFloat(bytes);
|
||||
allBytes += Float.parseFloat(bytes);
|
||||
index++;
|
||||
jtlSamplesSize++;
|
||||
}catch (Exception e){
|
||||
System.out.println("exception i:"+i);
|
||||
}
|
||||
}
|
||||
|
||||
Collections.sort(elapsedList);
|
||||
|
||||
int tp90 = elapsedList.size()*90/100;
|
||||
int tp95 = elapsedList.size()*95/100;
|
||||
int tp99 = elapsedList.size()*99/100;
|
||||
|
||||
list.sort(Comparator.comparing(t0 -> Long.valueOf(t0.getTimestamp())));
|
||||
long time = Long.parseLong(list.get(list.size()-1).getTimestamp()) - Long.parseLong(list.get(0).getTimestamp()) + Long.parseLong(list.get(list.size()-1).getElapsed());
|
||||
metricList.sort(Comparator.comparing(t0 -> Long.valueOf(t0.getTimestamp())));
|
||||
long time = Long.parseLong(metricList.get(metricList.size()-1).getTimestamp()) - Long.parseLong(metricList.get(0).getTimestamp())
|
||||
+ Long.parseLong(metricList.get(metricList.size()-1).getElapsed());
|
||||
|
||||
RequestStatistics requestStatistics = new RequestStatistics();
|
||||
requestStatistics.setRequestLabel(label);
|
||||
requestStatistics.setSamples(index);
|
||||
requestStatistics.setSamples(jtlSamplesSize);
|
||||
|
||||
String s = df.format((float)sumElapsed/index);
|
||||
requestStatistics.setAverage(s+"");
|
||||
String average = decimalFormat.format((float)oneLineElapsedTime / jtlSamplesSize);
|
||||
requestStatistics.setAverage(average);
|
||||
|
||||
/**
|
||||
* TP90的计算
|
||||
|
@ -103,80 +109,91 @@ public class JtlResolver {
|
|||
requestStatistics.setTp95(elapsedList.get(tp95)+"");
|
||||
requestStatistics.setTp99(elapsedList.get(tp99)+"");
|
||||
|
||||
double avgHits = (double)list.size() / (time * 1.0 / 1000);
|
||||
requestStatistics.setAvgHits(df.format(avgHits));
|
||||
double avgHits = (double)metricList.size() / (time * 1.0 / 1000);
|
||||
requestStatistics.setAvgHits(decimalFormat.format(avgHits));
|
||||
|
||||
requestStatistics.setMin(elapsedList.get(0)+"");
|
||||
requestStatistics.setMax(elapsedList.get(index-1)+"");
|
||||
requestStatistics.setErrors(df.format(failSize * 100.0 / index)+"%");
|
||||
requestStatistics.setMax(elapsedList.get(jtlSamplesSize-1)+"");
|
||||
requestStatistics.setErrors(decimalFormat.format(failSize * 100.0 / jtlSamplesSize)+"%");
|
||||
requestStatistics.setKo(failSize);
|
||||
/**
|
||||
* 所有的相同请求的bytes总和 / 1024 / 请求持续运行的时间=sum(bytes)/1024/total time
|
||||
* total time = 最大时间戳 - 最小时间戳 + 最后请求的响应时间
|
||||
*/
|
||||
requestStatistics.setKbPerSec(df.format(totalBytes * 1.0 / 1024 / (time * 1.0 / 1000)));
|
||||
requestStatistics.setKbPerSec(decimalFormat.format(oneLineBytes * 1.0 / 1024 / (time * 1.0 / 1000)));
|
||||
requestStatisticsList.add(requestStatistics);
|
||||
}
|
||||
|
||||
Collections.sort(allelapse);
|
||||
int totalTP90 = allelapse.size()*90/100;
|
||||
int totalTP95 = allelapse.size()*95/100;
|
||||
int totalTP99 = allelapse.size()*99/100;
|
||||
Collections.sort(allElapseTimeList);
|
||||
int totalTP90 = allElapseTimeList.size()*90/100;
|
||||
int totalTP95 = allElapseTimeList.size()*95/100;
|
||||
int totalTP99 = allElapseTimeList.size()*99/100;
|
||||
|
||||
Integer min = allelapse.get(0);
|
||||
Integer max = allelapse.get(allelapse.size() - 1);
|
||||
Integer min = allElapseTimeList.get(0);
|
||||
Integer max = allElapseTimeList.get(allElapseTimeList.size() - 1);
|
||||
|
||||
int allSamples = requestStatisticsList.stream().mapToInt(RequestStatistics::getSamples).sum();
|
||||
int failSize = requestStatisticsList.stream().mapToInt(RequestStatistics::getKo).sum();
|
||||
|
||||
double errors = (double)failSize / allSamples * 100;
|
||||
String totalerrors = df.format(errors);
|
||||
double average = (double)totalAverage / allSamples;
|
||||
String totalaverage = df.format(average);
|
||||
String totalErrors = decimalFormat.format(errors);
|
||||
double average = (double)totalElapsedTime / allSamples;
|
||||
String totalAverage = decimalFormat.format(average);
|
||||
|
||||
RequestStatisticsDTO statisticsDTO = new RequestStatisticsDTO();
|
||||
statisticsDTO.setRequestStatisticsList(requestStatisticsList);
|
||||
statisticsDTO.setTotalLabel("Total");
|
||||
statisticsDTO.setTotalSamples(String.valueOf(allSamples));
|
||||
statisticsDTO.setTotalErrors(totalerrors + "%");
|
||||
statisticsDTO.setTotalAverage(totalaverage);
|
||||
statisticsDTO.setTotalErrors(totalErrors + "%");
|
||||
statisticsDTO.setTotalAverage(totalAverage);
|
||||
statisticsDTO.setTotalMin(String.valueOf(min));
|
||||
statisticsDTO.setTotalMax(String.valueOf(max));
|
||||
statisticsDTO.setTotalTP90(String.valueOf(allelapse.get(totalTP90)));
|
||||
statisticsDTO.setTotalTP95(String.valueOf(allelapse.get(totalTP95)));
|
||||
statisticsDTO.setTotalTP99(String.valueOf(allelapse.get(totalTP99)));
|
||||
statisticsDTO.setTotalTP90(String.valueOf(allElapseTimeList.get(totalTP90)));
|
||||
statisticsDTO.setTotalTP95(String.valueOf(allElapseTimeList.get(totalTP95)));
|
||||
statisticsDTO.setTotalTP99(String.valueOf(allElapseTimeList.get(totalTP99)));
|
||||
|
||||
total.sort(Comparator.comparing(t0 -> Long.valueOf(t0.getTimestamp())));
|
||||
long ms = Long.valueOf(total.get(total.size()-1).getTimestamp()) - Long.valueOf(total.get(0).getTimestamp()) + Long.parseLong(total.get(total.size()-1).getElapsed());
|
||||
double avgThroughput = (double)total.size() / (ms * 1.0 / 1000);
|
||||
statisticsDTO.setTotalAvgHits(df.format(avgThroughput));
|
||||
totalLines.sort(Comparator.comparing(t0 -> Long.valueOf(t0.getTimestamp())));
|
||||
|
||||
long ms = Long.parseLong(totalLines.get(totalLines.size()-1).getTimestamp()) - Long.parseLong(totalLines.get(0).getTimestamp())
|
||||
+ Long.parseLong(totalLines.get(totalLines.size()-1).getElapsed());
|
||||
double avgThroughput = (double)totalLines.size() / (ms * 1.0 / 1000);
|
||||
|
||||
statisticsDTO.setTotalAvgHits(decimalFormat.format(avgThroughput));
|
||||
statisticsDTO.setTotalAvgBandwidth(decimalFormat.format(totalBytes * 1.0 / 1024 / (ms * 1.0 / 1000)));
|
||||
|
||||
statisticsDTO.setTotalAvgBandwidth(df.format(allBytes * 1.0 / 1024 / (ms * 1.0 / 1000)));
|
||||
return statisticsDTO;
|
||||
}
|
||||
|
||||
// report - Errors
|
||||
public static List<Errors> getErrorsList(String jtlString) {
|
||||
List<Metric> totalLines = resolver(jtlString);
|
||||
List<Metric> falseList = totalLines.stream().filter(metric -> StringUtils.equals("false", metric.getSuccess())).collect(Collectors.toList());
|
||||
List<Errors> errorsList = new ArrayList<>();
|
||||
Map<String, List<Metric>> collect = falseList.stream().collect(Collectors.groupingBy(JtlResolver::getResponseCodeAndFailureMessage));
|
||||
Iterator<Map.Entry<String, List<Metric>>> iterator = collect.entrySet().iterator();
|
||||
DecimalFormat df = new DecimalFormat("0.00");
|
||||
DecimalFormat decimalFormat = new DecimalFormat("0.00");
|
||||
|
||||
List<Metric> falseList = new ArrayList<>();
|
||||
for (Metric metric : totalLines) {
|
||||
if (StringUtils.equals("false", metric.getSuccess())) {
|
||||
falseList.add(metric);
|
||||
}
|
||||
}
|
||||
|
||||
Map<String, List<Metric>> jtlMap = falseList.stream().collect(Collectors.groupingBy(JtlResolver::getResponseCodeAndFailureMessage));
|
||||
Iterator<Map.Entry<String, List<Metric>>> iterator = jtlMap.entrySet().iterator();
|
||||
|
||||
while (iterator.hasNext()) {
|
||||
Map.Entry<String, List<Metric>> next = iterator.next();
|
||||
String key = next.getKey();
|
||||
List<Metric> value = next.getValue();
|
||||
List<Metric> metricList = next.getValue();
|
||||
Errors errors = new Errors();
|
||||
errors.setErrorType(key);
|
||||
errors.setErrorNumber(String.valueOf(value.size()));
|
||||
int errorSize = value.size();
|
||||
errors.setErrorNumber(String.valueOf(metricList.size()));
|
||||
int errorSize = metricList.size();
|
||||
int errorAllSize = falseList.size();
|
||||
int allSamples = totalLines.size();
|
||||
errors.setPrecentOfErrors(df.format((double)errorSize / errorAllSize * 100) + "%");
|
||||
errors.setPrecentOfAllSamples(df.format((double)errorSize / allSamples * 100) + "%");
|
||||
errors.setPrecentOfErrors(decimalFormat.format((double)errorSize / errorAllSize * 100) + "%");
|
||||
errors.setPrecentOfAllSamples(decimalFormat.format((double)errorSize / allSamples * 100) + "%");
|
||||
errorsList.add(errors);
|
||||
}
|
||||
|
||||
return errorsList;
|
||||
}
|
||||
|
||||
|
@ -184,33 +201,36 @@ public class JtlResolver {
|
|||
return metric.getResponseCode() + "/" + metric.getResponseMessage();
|
||||
}
|
||||
|
||||
// report - Errors Top 5
|
||||
public static ErrorsTop5DTO getErrorsTop5DTO(String jtlString) {
|
||||
List<Metric> totalLines = resolver(jtlString);
|
||||
ErrorsTop5DTO top5DTO = new ErrorsTop5DTO();
|
||||
List<Metric> falseList = totalLines.stream().filter(metric -> StringUtils.equals("false", metric.getSuccess())).collect(Collectors.toList());
|
||||
List<ErrorsTop5> errorsTop5s = new ArrayList<>();
|
||||
|
||||
List<Metric> falseList = Objects.requireNonNull(totalLines).stream().filter(metric -> StringUtils.equals("false", metric.getSuccess())).collect(Collectors.toList());
|
||||
Map<String, List<Metric>> collect = falseList.stream().collect(Collectors.groupingBy(JtlResolver::getResponseCodeAndFailureMessage));
|
||||
Iterator<Map.Entry<String, List<Metric>>> iterator = collect.entrySet().iterator();
|
||||
List<ErrorsTop5> errorsTop5s = new ArrayList<>();
|
||||
|
||||
while (iterator.hasNext()) {
|
||||
Map.Entry<String, List<Metric>> next = iterator.next();
|
||||
String key = next.getKey();
|
||||
List<Metric> value = next.getValue();
|
||||
ErrorsTop5 errorsTop5 = new ErrorsTop5();
|
||||
List<Metric> metricList = next.getValue();
|
||||
List<Metric> list = totalLines.stream()
|
||||
.filter(metric -> StringUtils.equals(metric.getLabel(), value.get(0).getLabel())).collect(Collectors.toList());
|
||||
.filter(metric -> StringUtils.equals(metric.getLabel(), metricList.get(0).getLabel()))
|
||||
.collect(Collectors.toList());
|
||||
|
||||
ErrorsTop5 errorsTop5 = new ErrorsTop5();
|
||||
errorsTop5.setSamples(String.valueOf(list.size()));
|
||||
errorsTop5.setSample(value.get(0).getLabel());
|
||||
errorsTop5.setErrors(String.valueOf(value.size()));
|
||||
errorsTop5.setErrorsAllSize(value.size());
|
||||
errorsTop5.setSample(metricList.get(0).getLabel());
|
||||
errorsTop5.setErrors(String.valueOf(metricList.size()));
|
||||
errorsTop5.setErrorsAllSize(metricList.size());
|
||||
errorsTop5.setError(key);
|
||||
errorsTop5s.add(errorsTop5);
|
||||
}
|
||||
|
||||
errorsTop5s.sort((t0, t1) -> t1.getErrorsAllSize().compareTo(t0.getErrorsAllSize()));
|
||||
|
||||
if (errorsTop5s.size() >= 5) {
|
||||
errorsTop5s = errorsTop5s.subList(0, 5);
|
||||
if (errorsTop5s.size() >= ERRORS_TOP_SIZE) {
|
||||
errorsTop5s = errorsTop5s.subList(0, ERRORS_TOP_SIZE);
|
||||
}
|
||||
|
||||
top5DTO.setLabel("Total");
|
||||
|
@ -233,23 +253,27 @@ public class JtlResolver {
|
|||
return top5DTO;
|
||||
}
|
||||
|
||||
// report - TestOverview
|
||||
public static TestOverview getTestOverview(String jtlString) {
|
||||
TestOverview testOverview = new TestOverview();
|
||||
List<Metric> total = JtlResolver.resolver(jtlString);
|
||||
Map<String, List<Metric>> collect = total.stream().collect(Collectors.groupingBy(Metric::getTimestamp));
|
||||
DecimalFormat decimalFormat = new DecimalFormat("0.00");
|
||||
|
||||
List<Metric> totalLineList = JtlResolver.resolver(jtlString);
|
||||
Map<String, List<Metric>> collect = totalLineList.stream().collect(Collectors.groupingBy(Metric::getTimestamp));
|
||||
Iterator<Map.Entry<String, List<Metric>>> iterator = collect.entrySet().iterator();
|
||||
int max = 0;
|
||||
int totalElapsed = 0;
|
||||
|
||||
int maxUsers = 0, totalElapsed = 0;
|
||||
float totalBytes = 0f;
|
||||
|
||||
while (iterator.hasNext()) {
|
||||
Map.Entry<String, List<Metric>> entry = iterator.next();
|
||||
List<Metric> list = entry.getValue();
|
||||
if (list.size() > max) {
|
||||
max = list.size();
|
||||
List<Metric> metricList = entry.getValue();
|
||||
|
||||
if (metricList.size() > maxUsers) {
|
||||
maxUsers = metricList.size();
|
||||
}
|
||||
for (int i = 0; i < list.size(); i++) {
|
||||
Metric metric = list.get(i);
|
||||
|
||||
for (int i = 0; i < metricList.size(); i++) {
|
||||
Metric metric = metricList.get(i);
|
||||
String elapsed = metric.getElapsed();
|
||||
totalElapsed += Integer.parseInt(elapsed);
|
||||
String bytes = metric.getBytes();
|
||||
|
@ -257,31 +281,30 @@ public class JtlResolver {
|
|||
}
|
||||
}
|
||||
|
||||
total.sort(Comparator.comparing(t0 -> Long.valueOf(t0.getTimestamp())));
|
||||
DecimalFormat df = new DecimalFormat("0.00");
|
||||
totalLineList.sort(Comparator.comparing(t0 -> Long.valueOf(t0.getTimestamp())));
|
||||
|
||||
testOverview.setMaxUsers(String.valueOf(max));
|
||||
testOverview.setMaxUsers(String.valueOf(maxUsers));
|
||||
|
||||
List<Metric> list90 = total.subList(0, total.size() * 9 / 10);
|
||||
List<Metric> list90 = totalLineList.subList(0, totalLineList.size() * 9 / 10);
|
||||
long sum = list90.stream().mapToLong(metric -> Long.parseLong(metric.getElapsed())).sum();
|
||||
double avg90 = (double)sum / 1000 / list90.size();
|
||||
testOverview.setResponseTime90(df.format(avg90));
|
||||
testOverview.setResponseTime90(decimalFormat.format(avg90));
|
||||
|
||||
Long timestamp1 = Long.valueOf(total.get(0).getTimestamp());
|
||||
Long timestamp2 = Long.valueOf(total.get(total.size()-1).getTimestamp());
|
||||
long time = timestamp2 - timestamp1 + Long.parseLong(total.get(total.size()-1).getElapsed());
|
||||
double avgThroughput = (double)total.size() / (time * 1.0 / 1000);
|
||||
testOverview.setAvgThroughput(df.format(avgThroughput));
|
||||
long timesStampStart = Long.parseLong(totalLineList.get(0).getTimestamp());
|
||||
long timesStampEnd = Long.parseLong(totalLineList.get(totalLineList.size()-1).getTimestamp());
|
||||
long time = timesStampEnd - timesStampStart + Long.parseLong(totalLineList.get(totalLineList.size()-1).getElapsed());
|
||||
double avgThroughput = (double)totalLineList.size() / (time * 1.0 / 1000);
|
||||
testOverview.setAvgThroughput(decimalFormat.format(avgThroughput));
|
||||
|
||||
List<Metric> falseList = total.stream().filter(metric -> StringUtils.equals("false", metric.getSuccess())).collect(Collectors.toList());
|
||||
double errors = falseList.size() * 1.0 / total.size() * 100;
|
||||
testOverview.setErrors(df.format(errors));
|
||||
List<Metric> falseList = totalLineList.stream().filter(metric -> StringUtils.equals("false", metric.getSuccess())).collect(Collectors.toList());
|
||||
double errors = falseList.size() * 1.0 / totalLineList.size() * 100;
|
||||
testOverview.setErrors(decimalFormat.format(errors));
|
||||
|
||||
double avg = totalElapsed * 1.0 / total.size() / 1000; // s
|
||||
testOverview.setAvgResponseTime(df.format(avg));
|
||||
double avg = totalElapsed * 1.0 / totalLineList.size() / 1000;
|
||||
testOverview.setAvgResponseTime(decimalFormat.format(avg));
|
||||
|
||||
double bandwidth = totalBytes * 1.0 / time;
|
||||
testOverview.setAvgBandwidth(df.format(bandwidth));
|
||||
testOverview.setAvgBandwidth(decimalFormat.format(bandwidth));
|
||||
|
||||
return testOverview;
|
||||
}
|
||||
|
@ -293,13 +316,12 @@ public class JtlResolver {
|
|||
|
||||
List<String> users = new ArrayList<>();
|
||||
List<String> hits = new ArrayList<>();
|
||||
List<String> erorrs = new ArrayList<>();
|
||||
List<String> errors = new ArrayList<>();
|
||||
List<String> timeList = new ArrayList<>();
|
||||
Map<String, Object> resultMap = new HashMap<>();
|
||||
Map<String, Object> resultMap = new HashMap<>(5);
|
||||
|
||||
// todo SimpleDateFormat
|
||||
SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
||||
DecimalFormat df = new DecimalFormat("0.0");
|
||||
DecimalFormat decimalFormat = new DecimalFormat("0.0");
|
||||
|
||||
total.sort(Comparator.comparing(metric -> Long.valueOf(metric.getTimestamp())));
|
||||
total.forEach(metric -> {
|
||||
|
@ -337,27 +359,27 @@ public class JtlResolver {
|
|||
}
|
||||
// todo
|
||||
timeList.add(map.getKey());
|
||||
hits.add(df.format(metrics.size() * 1.0 / maxUsers));
|
||||
hits.add(decimalFormat.format(metrics.size() * 1.0 / maxUsers));
|
||||
users.add(String.valueOf(maxUsers));
|
||||
erorrs.add(String.valueOf(failSize));
|
||||
errors.add(String.valueOf(failSize));
|
||||
|
||||
}
|
||||
|
||||
resultMap.put("users", users);
|
||||
resultMap.put("hits", hits);
|
||||
resultMap.put("errors", erorrs);
|
||||
resultMap.put("errors", errors);
|
||||
|
||||
JSONObject serices = new JSONObject(resultMap);
|
||||
data.setxAxis(StringUtils.join(",", timeList));
|
||||
data.setSerices(serices.toString());
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
private static String stampToDate(String s){
|
||||
String res;
|
||||
SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
||||
long lt = Long.parseLong(s);
|
||||
Date date = new Date(lt);
|
||||
res = simpleDateFormat.format(date);
|
||||
return res;
|
||||
return simpleDateFormat.format(date);
|
||||
}
|
||||
}
|
|
@ -129,7 +129,21 @@
|
|||
data() {
|
||||
return {
|
||||
tableData: [{},{},{},{},{}],
|
||||
errorTotal: {},
|
||||
errorTotal: {
|
||||
label: '',
|
||||
totalSamples: '',
|
||||
totalErrors: '',
|
||||
error1: '',
|
||||
error1Size: '',
|
||||
error2: '',
|
||||
error2Size: '',
|
||||
error3: '',
|
||||
error3Size: '',
|
||||
error4: '',
|
||||
error4Size: '',
|
||||
error5: '',
|
||||
error5Size: ''
|
||||
},
|
||||
errorTop5: []
|
||||
}
|
||||
},
|
||||
|
|
|
@ -80,7 +80,19 @@
|
|||
data() {
|
||||
return {
|
||||
tableData: [{},{},{},{},{}],
|
||||
totalInfo: {}
|
||||
totalInfo: {
|
||||
totalLabel: '',
|
||||
totalSamples: '',
|
||||
totalErrors: '',
|
||||
totalAverage: '',
|
||||
totalMin: '',
|
||||
totalMax: '',
|
||||
totalTP90: '',
|
||||
totalTP95: '',
|
||||
totalTP99: '',
|
||||
totalAvgHits: '',
|
||||
totalAvgBandwidth: ''
|
||||
}
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
|
|
Loading…
Reference in New Issue