提交 91d78234 编写于 作者: S shiziyuan9527

测试概览图表时间

上级 6a4af34b
......@@ -344,8 +344,13 @@ public class JtlResolver {
failSize++;
}
}
// todo
timeList.add(entry.getKey());
try {
timeList.add(formatDate(entry.getKey()));
} catch (ParseException e) {
e.printStackTrace();
}
hits.add(decimalFormat.format(metrics.size() * 1.0 / maxUsers));
users.add(String.valueOf(maxUsers));
errors.add(String.valueOf(failSize));
......@@ -357,7 +362,7 @@ public class JtlResolver {
resultMap.put("errors", errors);
JSONObject serices = new JSONObject(resultMap);
data.setxAxis(StringUtils.join(",", timeList));
data.setxAxis(String.join(",", timeList));
data.setSerices(serices.toString());
return data;
......@@ -384,7 +389,13 @@ public class JtlResolver {
Map<String, List<Metric>> metricsMap = metricList.stream().collect(Collectors.groupingBy(Metric::getThreadName));
int maxUsers = metricsMap.size();
int sumElapsedTime = metricList.stream().mapToInt(metric -> Integer.parseInt(metric.getElapsed())).sum();
timestampList.add(entry.getKey());
try {
timestampList.add(formatDate(entry.getKey()));
} catch (ParseException e) {
e.printStackTrace();
}
users.add(String.valueOf(maxUsers));
resTimeList.add(String.valueOf(sumElapsedTime / metricList.size()));
}
......@@ -393,7 +404,7 @@ public class JtlResolver {
resultMap.put("users", users);
resultMap.put("resTime", resTimeList);
JSONObject serices = new JSONObject(resultMap);
chartsData.setxAxis(StringUtils.join(",", timestampList));
chartsData.setxAxis(String.join(",", timestampList));
chartsData.setSerices(serices.toString());
return chartsData;
}
......@@ -405,6 +416,16 @@ public class JtlResolver {
return simpleDateFormat.format(date);
}
/**
* @param "yyyy-MM-dd HH:mm:ss"
* @return "HH:mm:ss"
*/
private static String formatDate(String dateString) throws ParseException {
SimpleDateFormat before = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
SimpleDateFormat after = new SimpleDateFormat("HH:mm:ss");
return after.format(before.parse(dateString));
}
private static int sortByDate(Map.Entry<String, List<Metric>> map1, Map.Entry<String, List<Metric>> map2) {
SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
Date date1 = null, date2 = null;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册