1# Copyright (c) 2013 The Chromium OS Authors. All rights reserved. 2# Use of this source code is governed by a BSD-style license that can be 3# found in the LICENSE file. 4 5from autotest_lib.server import test 6from autotest_lib.server.cros import telemetry_runner 7 8 9class telemetry_Benchmarks(test.test): 10 """Run a telemetry benchmark.""" 11 version = 1 12 13 14 def run_once(self, host=None, benchmark=None, args={}): 15 """Run a telemetry benchmark. 16 17 @param host: hostname(ip address) to run the telemetry benchmark on. 18 @param benchmark: telemetry benchmark test to run. 19 """ 20 local = args.get("local") == "True" 21 optional = {} 22 telemetry_on_dut = args.get("telemetry_on_dut") 23 if telemetry_on_dut: 24 optional["telemetry_on_dut"] = telemetry_on_dut == "True" 25 telemetry = telemetry_runner.TelemetryRunner(host, local, **optional) 26 perf_value_writer = self 27 extra_args = args.get("extra_args", []) 28 repeat = args.get("pageset_repeat") 29 if repeat is not None: 30 extra_args.append('--pageset-repeat=%s' % repeat) 31 32 # TODO(chinglinyu): crbug/1041328: Use legacy JSON trace temporarily. 33 # Remove after perfetto trace_processor_shell is enabled. 34 extra_args.append('--legacy-json-trace-format') 35 36 telemetry.run_telemetry_benchmark(benchmark, perf_value_writer, 37 *extra_args) 38