Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Fix] Fix undefine parsed data and invalid date #428

Merged
merged 2 commits into from
Apr 13, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
import javax.persistence.Id;
import java.io.Serializable;
import java.lang.reflect.Field;
import java.sql.Date;
import java.util.Date;
import java.util.LinkedHashMap;
import java.util.Map;
import java.util.UUID;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
import com.microsoft.hydralab.performance.PerformanceResultParser;
import com.microsoft.hydralab.performance.PerformanceTestResult;
import com.microsoft.hydralab.performance.entity.AndroidBatteryInfo;
import org.apache.commons.lang3.SerializationUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

Expand Down Expand Up @@ -43,13 +42,29 @@ public PerformanceTestResult parse(PerformanceTestResult performanceTestResult)
}

// Use the battery usage at the end of the test as a summary
performanceTestResult.setResultSummary(SerializationUtils.clone(
(AndroidBatteryInfo) inspectionResults.get(inspectionResults.size() - 1).parsedData));
performanceTestResult.setResultSummary(getResultSummary(inspectionResults));
return performanceTestResult;
}

private AndroidBatteryInfo getResultSummary(List<PerformanceInspectionResult> inspectionResults) {
if (inspectionResults == null || inspectionResults.isEmpty()) {
return null;
}

for (int i = inspectionResults.size() - 1; i >= 0; i--) {
PerformanceInspectionResult inspectionResult = inspectionResults.get(i);
if (inspectionResult.parsedData != null) {
return (AndroidBatteryInfo) inspectionResult.parsedData;
}
}

return null;
}

private AndroidBatteryInfo parseRawResultFile(File rawFile, String packageName) {
if (!rawFile.isFile() || !rawFile.exists()) return null;
if (!rawFile.isFile() || !rawFile.exists()) {
taoran6 marked this conversation as resolved.
Show resolved Hide resolved
taoran6 marked this conversation as resolved.
Show resolved Hide resolved
return null;
}

AndroidBatteryInfo batteryInfo = new AndroidBatteryInfo();
float totalUsage = 0.0f;
Expand Down
10 changes: 5 additions & 5 deletions react/src/component/PerfTestDashboard.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ export default class PerfTestDashboard extends React.Component {
if (isAndroidBatteryInfoEnabled) {
let startTime = androidBatteryInfo.performanceInspectionResults[0].timestamp;
androidBatteryInfo.performanceInspectionResults.forEach((inspectionResult) => {
if (inspectionResult.parsedData !== null) {
if (inspectionResult && inspectionResult.parsedData) {
let result = { ...inspectionResult.parsedData };
result.time = (inspectionResult.timestamp - startTime) / 1000;
result.ratio = inspectionResult.parsedData.ratio * 100;
Expand Down Expand Up @@ -187,7 +187,7 @@ export default class PerfTestDashboard extends React.Component {
if (isAndroidMemoryInfoEnabled) {
let startTime = androidMemoryInfo.performanceInspectionResults[0].timestamp;
androidMemoryInfo.performanceInspectionResults.forEach((inspectionResult) => {
if (inspectionResult.parsedData !== null) {
if (inspectionResult && inspectionResult.parsedData) {
let result = { ...inspectionResult.parsedData };
result.time = (inspectionResult.timestamp - startTime) / 1000;
Object.keys(inspectionResult.parsedData).forEach((key) => {
Expand Down Expand Up @@ -241,7 +241,7 @@ export default class PerfTestDashboard extends React.Component {
let startTime = windowsMemoryInfo.performanceInspectionResults[0].timestamp;
windowsMemoryInfo.performanceInspectionResults.forEach((inspectionResult) => {

if (inspectionResult !== null && inspectionResult.parsedData !== null) {
if (inspectionResult && inspectionResult.parsedData) {
var result = { ...inspectionResult.parsedData };
let parsedData = { ...inspectionResult.parsedData };
result.time = (inspectionResult.timestamp - startTime) / 1000;
Expand Down Expand Up @@ -308,7 +308,7 @@ export default class PerfTestDashboard extends React.Component {
let startTime = iosEnergyInfo.performanceInspectionResults[0].timestamp;
iosEnergyInfo.performanceInspectionResults.forEach((inspectionResult) => {

if (inspectionResult !== null && inspectionResult.parsedData !== null) {
if (inspectionResult && inspectionResult.parsedData) {
var result = { ...inspectionResult.parsedData };
let parsedData = { ...inspectionResult.parsedData };
result.time = (inspectionResult.timestamp - startTime) / 1000;
Expand Down Expand Up @@ -357,7 +357,7 @@ export default class PerfTestDashboard extends React.Component {
let startTime = iosMemoryInfo.performanceInspectionResults[0].timestamp;
iosMemoryInfo.performanceInspectionResults.forEach((inspectionResult) => {

if (inspectionResult !== null && inspectionResult.parsedData !== null) {
if (inspectionResult && inspectionResult.parsedData) {
var result = { ...inspectionResult.parsedData };
let parsedData = { ...inspectionResult.parsedData };
result.time = (inspectionResult.timestamp - startTime) / 1000;
Expand Down