Skip to content

Commit

Permalink
[Perf] Add performance history chart (#409)
Browse files Browse the repository at this point in the history
* [Perf] Perf history chart

* Remove unused codes
  • Loading branch information
taoran6 committed Apr 4, 2023
1 parent dad7fdb commit 19921c3
Show file tree
Hide file tree
Showing 4 changed files with 199 additions and 79 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
import javax.persistence.criteria.CriteriaQuery;
import javax.persistence.criteria.Root;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Optional;
import java.util.Set;
Expand Down Expand Up @@ -245,6 +246,10 @@ public void checkTestDataAuthorization(SysUser requestor, String testId) {

public List<PerformanceTestResultEntity> getPerformanceTestHistory(List<CriteriaType> queryParams) {
Specification<PerformanceTestResultEntity> spec = new CriteriaTypeUtil<PerformanceTestResultEntity>().transferToSpecification(queryParams, false);
return performanceTestResultRepository.findAll(spec);
//TODO set page
PageRequest pageRequest = PageRequest.of(0, 10, Sort.by(Sort.Direction.DESC, "Date"));
List<PerformanceTestResultEntity> perfHistoryList = new ArrayList<>(performanceTestResultRepository.findAll(spec, pageRequest).getContent());
Collections.reverse(perfHistoryList);
return perfHistoryList;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@

public class AndroidMemoryInfoResultParser implements PerformanceResultParser {
private static final int MEM_INFO_LENGTH = 19;
private static final String SUMMARY_DESCRIPTION = "Android memory info summary";
private final Logger logger = LoggerFactory.getLogger(getClass());
private static final Map<String, Integer> MEMORY_FILE_TO_DB_INDEX_MAP = new HashMap<>() {
{
Expand Down Expand Up @@ -54,7 +55,7 @@ public PerformanceTestResult parse(PerformanceTestResult performanceTestResult)
}
}

performanceTestResult.setResultSummary(buildAverageMemoryInfo(averageMemoryInfo, inspectionResults.get(0)));
performanceTestResult.setResultSummary(buildAverageMemoryInfo(averageMemoryInfo, inspectionResults.get(0), SUMMARY_DESCRIPTION));

return performanceTestResult;
}
Expand All @@ -81,12 +82,16 @@ private boolean isValidMem(long[] memInfo) {
return false;
}

private AndroidMemoryInfo buildAverageMemoryInfo(double[] averageMemoryInfo, PerformanceInspectionResult inspectionResult) {
private AndroidMemoryInfo buildAverageMemoryInfo(double[] averageMemoryInfo, PerformanceInspectionResult inspectionResult, String description) {
long[] averageMemoryInfoLong = new long[averageMemoryInfo.length];
boolean isValidSummary = false;
for (int i = 0; i < averageMemoryInfo.length; i++) {
if (averageMemoryInfo[i] > 0) {
isValidSummary = true;
}
averageMemoryInfoLong[i] = Math.round(averageMemoryInfo[i]);
}
return buildMemoryInfo(inspectionResult.inspection.appId, inspectionResult.inspection.description, inspectionResult.timestamp, averageMemoryInfoLong);
return isValidSummary ? buildMemoryInfo(inspectionResult.inspection.appId, description, inspectionResult.timestamp, averageMemoryInfoLong) : null;
}

private AndroidMemoryInfo buildMemoryInfo(String packageName, String description, long timestamp, long[] memInfos) {
Expand Down
Loading

0 comments on commit 19921c3

Please sign in to comment.