1
0
mirror of https://github.com/ARM-software/workload-automation.git synced 2025-03-20 17:48:44 +00:00

Changes after review of pull #5

- Use superclass writeToFile - improved to accept generic Map collections
- Change timer results format to one more in line with the rest
This commit is contained in:
muendelezaji 2016-05-05 20:07:51 +01:00
parent f648cbe614
commit cde0b12c5d
11 changed files with 23 additions and 44 deletions

View File

@ -36,8 +36,6 @@ import java.util.logging.Level;
import java.util.logging.Logger; import java.util.logging.Logger;
import java.util.Arrays; import java.util.Arrays;
import java.util.List; import java.util.List;
import java.util.LinkedHashMap;
import java.util.Iterator;
import java.util.Map; import java.util.Map;
import java.util.Map.Entry; import java.util.Map.Entry;
@ -253,19 +251,18 @@ public class UxPerfUiAutomation extends BaseUiAutomation {
} }
} }
public void writeResultsToFile(LinkedHashMap timingResults, String file) throws Exception { public void writeResultsToFile(Map<String, Timer> results, String file) throws Exception {
// Write out the key/value pairs to the instrumentation log file // Write out the key/value pairs to the instrumentation log file
FileWriter fstream = new FileWriter(file); BufferedWriter out = new BufferedWriter(new FileWriter(file));
BufferedWriter out = new BufferedWriter(fstream); long start, finish, duration;
Iterator<Entry<String, Timer>> it = timingResults.entrySet().iterator(); Timer timer;
for (Map.Entry<String, Timer> entry : results.entrySet()) {
while (it.hasNext()) { timer = entry.getValue();
Map.Entry<String, Timer> pairs = it.next(); start = timer.getStart();
Timer results = pairs.getValue(); finish = timer.getFinish();
long start = results.getStart(); duration = timer.getDuration();
long finish = results.getFinish(); // Format used to parse out results in workload's update_result function
long duration = results.getDuration(); out.write(String.format("%s %d %d %d\n", entry.getKey(), start, finish, duration));
out.write(String.format(pairs .getKey() + " " + start + " " + finish + " " + duration + "\n"));
} }
out.close(); out.close();
} }

View File

@ -14,6 +14,7 @@
# #
import os.path as op import os.path as op
import re
import time import time
from wlauto import AndroidUiAutoBenchmark, Parameter from wlauto import AndroidUiAutoBenchmark, Parameter
@ -109,13 +110,14 @@ class Skype(AndroidUiAutoBenchmark):
# process results and add them using # process results and add them using
# context.result.add_metric # context.result.add_metric
with open(results_file, 'r') as lines: with open(results_file, 'r') as wfh:
for line in lines: regex = re.compile(r'(\w+)\s+(\d+)\s+(\d+)\s+(\d+)')
if line.startswith('timer:'): for line in wfh:
res = line.split(' ') match = regex.search(line)
context.result.add_metric(res[1] + '_start', res[2]) if match:
context.result.add_metric(res[1] + '_finish', res[3]) context.result.add_metric((match.group(1) + "_start"), match.group(2))
context.result.add_metric(res[1] + '_duration', res[4]) context.result.add_metric((match.group(1) + "_finish"), match.group(3))
context.result.add_metric((match.group(1) + "_duration"), match.group(4))
def teardown(self, context): def teardown(self, context):
self.logger.info('===== teardown() ======') self.logger.info('===== teardown() ======')

View File

@ -1,11 +1,8 @@
package com.arm.wlauto.uiauto.skype; package com.arm.wlauto.uiauto.skype;
import java.io.File; import java.io.File;
import java.io.BufferedWriter;
import java.io.FileWriter;
import java.util.TreeMap; import java.util.TreeMap;
import java.util.Map; import java.util.Map;
import java.util.Map.Entry;
import android.app.Activity; import android.app.Activity;
import android.os.Bundle; import android.os.Bundle;
@ -30,8 +27,6 @@ public class UiAutomation extends UxPerfUiAutomation {
public static final String PACKAGE_ID = "com.skype.raider:id/"; public static final String PACKAGE_ID = "com.skype.raider:id/";
public static final String TEXT_VIEW = "android.widget.TextView"; public static final String TEXT_VIEW = "android.widget.TextView";
public static String noContactMessage = "Could not find contact \"%s\" in the contacts list.";
private Map<String, Timer> results = new TreeMap<String, Timer>(); private Map<String, Timer> results = new TreeMap<String, Timer>();
private boolean dumpsysEnabled; private boolean dumpsysEnabled;
private String outputDir; private String outputDir;
@ -62,22 +57,7 @@ public class UiAutomation extends UxPerfUiAutomation {
} }
// Save results // Save results
saveResults(results, resultsFile); writeResultsToFile(results, resultsFile);
}
private void saveResults(Map<String, Timer> results, String file) throws Exception {
BufferedWriter out = new BufferedWriter(new FileWriter(file));
long start, finish, duration;
Timer timer;
for (Map.Entry<String, Timer> entry : results.entrySet()) {
timer = entry.getValue();
start = timer.getStart();
finish = timer.getFinish();
duration = timer.getDuration();
// Format used to parse out results in workload's update_result function
out.write(String.format("timer: %s %d %d %d\n", entry.getKey(), start, finish, duration));
}
out.close();
} }
private void handleLoginScreen(String username, String password) throws Exception { private void handleLoginScreen(String username, String password) throws Exception {
@ -155,8 +135,8 @@ public class UiAutomation extends UxPerfUiAutomation {
sleep(duration); sleep(duration);
if (video && dumpsysEnabled) { if (video && dumpsysEnabled) {
exitDumpsysSurfaceFlinger(PACKAGE, viewName, new File(outputDir, dumpsysTag + "_surface_flinger.log")); exitDumpsysSurfaceFlinger(PACKAGE, viewName, new File(outputDir, dumpsysTag + "_surfFlinger.log"));
exitDumpsysGfxInfo(PACKAGE, new File(outputDir, dumpsysTag + "_gfxinfo.log")); exitDumpsysGfxInfo(PACKAGE, new File(outputDir, dumpsysTag + "_gfxInfo.log"));
} }
} }