mirror of
				https://github.com/ARM-software/workload-automation.git
				synced 2025-10-30 22:54:18 +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:
		| @@ -14,6 +14,7 @@ | ||||
| # | ||||
|  | ||||
| import os.path as op | ||||
| import re | ||||
| import time | ||||
|  | ||||
| from wlauto import AndroidUiAutoBenchmark, Parameter | ||||
| @@ -109,13 +110,14 @@ class Skype(AndroidUiAutoBenchmark): | ||||
|  | ||||
|         # process results and add them using | ||||
|         # context.result.add_metric | ||||
|         with open(results_file, 'r') as lines: | ||||
|             for line in lines: | ||||
|                 if line.startswith('timer:'): | ||||
|                     res = line.split(' ') | ||||
|                     context.result.add_metric(res[1] + '_start', res[2]) | ||||
|                     context.result.add_metric(res[1] + '_finish', res[3]) | ||||
|                     context.result.add_metric(res[1] + '_duration', res[4]) | ||||
|         with open(results_file, 'r') as wfh: | ||||
|             regex = re.compile(r'(\w+)\s+(\d+)\s+(\d+)\s+(\d+)') | ||||
|             for line in wfh: | ||||
|                 match = regex.search(line) | ||||
|                 if match: | ||||
|                     context.result.add_metric((match.group(1) + "_start"), match.group(2)) | ||||
|                     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): | ||||
|         self.logger.info('===== teardown() ======') | ||||
|   | ||||
										
											Binary file not shown.
										
									
								
							| @@ -1,11 +1,8 @@ | ||||
| package com.arm.wlauto.uiauto.skype; | ||||
|  | ||||
| import java.io.File; | ||||
| import java.io.BufferedWriter; | ||||
| import java.io.FileWriter; | ||||
| import java.util.TreeMap; | ||||
| import java.util.Map; | ||||
| import java.util.Map.Entry; | ||||
|  | ||||
| import android.app.Activity; | ||||
| 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 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 boolean dumpsysEnabled; | ||||
|     private String outputDir; | ||||
| @@ -62,22 +57,7 @@ public class UiAutomation extends UxPerfUiAutomation { | ||||
|         } | ||||
|  | ||||
|         // Save results | ||||
|         saveResults(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(); | ||||
|         writeResultsToFile(results, resultsFile); | ||||
|     } | ||||
|  | ||||
|     private void handleLoginScreen(String username, String password) throws Exception { | ||||
| @@ -155,8 +135,8 @@ public class UiAutomation extends UxPerfUiAutomation { | ||||
|         sleep(duration); | ||||
|  | ||||
|         if (video && dumpsysEnabled) { | ||||
|             exitDumpsysSurfaceFlinger(PACKAGE, viewName, new File(outputDir, dumpsysTag + "_surface_flinger.log")); | ||||
|             exitDumpsysGfxInfo(PACKAGE, new File(outputDir, dumpsysTag + "_gfxinfo.log")); | ||||
|             exitDumpsysSurfaceFlinger(PACKAGE, viewName, new File(outputDir, dumpsysTag + "_surfFlinger.log")); | ||||
|             exitDumpsysGfxInfo(PACKAGE, new File(outputDir, dumpsysTag + "_gfxInfo.log")); | ||||
|         } | ||||
|     } | ||||
|  | ||||
|   | ||||
		Reference in New Issue
	
	Block a user