diff options
author | TreeHugger Robot <treehugger-gerrit@google.com> | 2017-05-23 14:23:22 +0000 |
---|---|---|
committer | Android (Google) Code Review <android-gerrit@google.com> | 2017-05-23 14:23:24 +0000 |
commit | 517175efdd632400bb1e66a51e2e13bc4f34629a (patch) | |
tree | 0f4652111cc84f473c892b0f23f6ba5971881fa7 | |
parent | 9f71788b334162db1be230302b9a3583d9c53523 (diff) | |
parent | 8dd47a2267d77dbd8db31c228ecaeba47b3ffcd7 (diff) | |
download | performance-517175efdd632400bb1e66a51e2e13bc4f34629a.tar.gz |
Merge "Change performance output format to JSON." into oc-dev
-rw-r--r-- | binder_benchmark/BinderPerformanceTest.py | 32 | ||||
-rw-r--r-- | hwbinder_benchmark/HwBinderPerformanceTest.py | 34 |
2 files changed, 21 insertions, 45 deletions
diff --git a/binder_benchmark/BinderPerformanceTest.py b/binder_benchmark/BinderPerformanceTest.py index bade992..919225a 100644 --- a/binder_benchmark/BinderPerformanceTest.py +++ b/binder_benchmark/BinderPerformanceTest.py @@ -23,6 +23,8 @@ from vts.runners.host import const from vts.runners.host import test_runner from vts.utils.python.controllers import android_device from vts.utils.python.cpu import cpu_frequency_scaling +from vts.utils.python.performance import benchmark_parser + class BinderPerformanceTest(base_test.BaseTestClass): """A testcase for the Binder Performance Benchmarking. @@ -68,7 +70,6 @@ class BinderPerformanceTest(base_test.BaseTestClass): "64k": 1000000, } } - LABEL_PREFIX = "BM_sendVec_binder/" def setUpClass(self): self.dut = self.registerController(android_device)[0] @@ -110,33 +111,22 @@ class BinderPerformanceTest(base_test.BaseTestClass): results = self.dut.shell.one.Execute([ "chmod 755 %s" % binary, "LD_LIBRARY_PATH=/data/local/tmp/%s/hw:" - "/data/local/tmp/%s:" - "$LD_LIBRARY_PATH %s" % (bits, bits, binary) + "/data/local/tmp/%s:$LD_LIBRARY_PATH " + "%s --benchmark_format=json" % (bits, bits, binary) ]) # Parses the result. asserts.assertEqual(len(results[const.STDOUT]), 2) + logging.info("stderr: %s", results[const.STDERR][1]) + logging.info("stdout: %s", results[const.STDOUT][1]) asserts.assertFalse( any(results[const.EXIT_CODE]), "BinderPerformanceTest failed.") - logging.info("stderr: %s", results[const.STDERR][1]) - stdout_lines = results[const.STDOUT][1].split("\n") - logging.info("stdout: %s", stdout_lines) - label_result = [] - value_result = [] - for line in stdout_lines: - if line.startswith(self.LABEL_PREFIX): - tokens = line.split() - benchmark_name = tokens[0] - time_in_ns = tokens[1].split()[0] - logging.info(benchmark_name) - logging.info(time_in_ns) - label_result.append( - benchmark_name.replace(self.LABEL_PREFIX, "")) - value_result.append(int(time_in_ns)) - - logging.info("result label for %sbits: %s", bits, label_result) - logging.info("result value for %sbits: %s", bits, value_result) + parser = benchmark_parser.GoogleBenchmarkJsonParser( + results[const.STDOUT][1]) + label_result = parser.getArguments() + value_result = parser.getRealTime() + # To upload to the web DB. self.web.AddProfilingDataLabeledVector( "binder_vector_roundtrip_latency_benchmark_%sbits" % bits, diff --git a/hwbinder_benchmark/HwBinderPerformanceTest.py b/hwbinder_benchmark/HwBinderPerformanceTest.py index 9135316..bc5aade 100644 --- a/hwbinder_benchmark/HwBinderPerformanceTest.py +++ b/hwbinder_benchmark/HwBinderPerformanceTest.py @@ -23,6 +23,7 @@ from vts.runners.host import const from vts.runners.host import test_runner from vts.utils.python.controllers import android_device from vts.utils.python.cpu import cpu_frequency_scaling +from vts.utils.python.performance import benchmark_parser class HwBinderPerformanceTest(base_test.BaseTestClass): @@ -69,8 +70,6 @@ class HwBinderPerformanceTest(base_test.BaseTestClass): "64k": 200000, } } - LABEL_PREFIX_BINDERIZE = "BM_sendVec_binderize/" - LABEL_PREFIX_PASSTHROUGH = "BM_sendVec_passthrough/" def setUpClass(self): required_params = ["hidl_hal_mode"] @@ -117,36 +116,23 @@ class HwBinderPerformanceTest(base_test.BaseTestClass): results = self.dut.shell.one.Execute([ "chmod 755 %s" % binary, "LD_LIBRARY_PATH=/system/lib%s:/data/local/tmp/%s/hw:" - "/data/local/tmp/%s:" - "$LD_LIBRARY_PATH %s -m %s" % + "/data/local/tmp/%s:$LD_LIBRARY_PATH " + "%s -m %s --benchmark_format=json" % (bits, bits, bits, binary, self.hidl_hal_mode.encode("utf-8")) ]) # Parses the result. asserts.assertEqual(len(results[const.STDOUT]), 2) + logging.info("stderr: %s", results[const.STDERR][1]) + logging.info("stdout: %s", results[const.STDOUT][1]) asserts.assertFalse( any(results[const.EXIT_CODE]), "HwBinderPerformanceTest failed.") - logging.info("stderr: %s", results[const.STDERR][1]) - stdout_lines = results[const.STDOUT][1].split("\n") - logging.info("stdout: %s", stdout_lines) - label_result = [] - value_result = [] - prefix = (self.LABEL_PREFIX_BINDERIZE - if self.hidl_hal_mode == "BINDERIZE" else - self.LABEL_PREFIX_PASSTHROUGH) - for line in stdout_lines: - if line.startswith(prefix): - tokens = line.split() - benchmark_name = tokens[0] - time_in_ns = tokens[1].split()[0] - logging.info(benchmark_name) - logging.info(time_in_ns) - label_result.append(benchmark_name.replace(prefix, "")) - value_result.append(int(time_in_ns)) - - logging.info("result label for %sbits: %s", bits, label_result) - logging.info("result value for %sbits: %s", bits, value_result) + parser = benchmark_parser.GoogleBenchmarkJsonParser( + results[const.STDOUT][1]) + label_result = parser.getArguments() + value_result = parser.getRealTime() + # To upload to the web DB. self.web.AddProfilingDataLabeledVector( "hwbinder_vector_roundtrip_latency_benchmark_%sbits" % bits, |