def runBinaryBenchmark()

in benchmarking/platforms/android/android_platform.py [0:0]


    def runBinaryBenchmark(self, cmd, *args, **kwargs):
        log_to_screen_only = (
            "log_to_screen_only" in kwargs and kwargs["log_to_screen_only"]
        )
        platform_args = {}
        if "platform_args" in kwargs:
            platform_args = kwargs["platform_args"]
            if "taskset" in platform_args:
                taskset = platform_args["taskset"]
                cmd = ["taskset", taskset] + cmd
                del platform_args["taskset"]
            if "sleep_before_run" in platform_args:
                sleep_before_run = str(platform_args["sleep_before_run"])
                cmd = ["sleep", sleep_before_run, "&&"] + cmd
                del platform_args["sleep_before_run"]
            if "power" in platform_args and platform_args["power"]:
                # launch settings page to prevent the phone
                # to go into sleep mode
                self.util.shell(["am", "start", "-a", "android.settings.SETTINGS"])
                time.sleep(1)
                cmd = (
                    ["nohup"]
                    + ["sh", "-c", "'" + " ".join(cmd) + "'"]
                    + [">", "/dev/null", "2>&1"]
                )
                platform_args["non_blocking"] = True
                del platform_args["power"]
            enable_profiling = platform_args.get("profiling_args", {}).get(
                "enabled", False
            )
            if enable_profiling:
                profiler = platform_args["profiling_args"]["profiler"]
                profiling_types = platform_args["profiling_args"]["types"]
                if profiler == "simpleperf":
                    assert profiling_types == [
                        "cpu"
                    ], "Only cpu profiling is supported for SimplePerf"
                    try:
                        # attempt to run with cpu profiling, else fallback to standard run
                        return self._runBenchmarkWithSimpleperf(
                            cmd, log_to_screen_only, **platform_args
                        )
                    except Exception:
                        # if this has not succeeded for some reason reset run status and run without profiling.
                        getLogger().critical(
                            f"An error has occurred when running Simpleperf profiler on device {self.platform} {self.platform_hash}.",
                            exc_info=True,
                        )
                elif profiler == "perfetto":
                    assert (
                        "cpu" not in profiling_types
                    ), "cpu profiling is not yet implemented for Perfetto"
                    try:
                        # attempt Perfetto profiling
                        return self._runBenchmarkWithPerfetto(
                            cmd, log_to_screen_only, **platform_args
                        )
                    except Exception:
                        # if this has not succeeded for some reason reset run status and run without profiling.
                        getLogger().critical(
                            f"An error has occurred when running Perfetto profiler on device {self.platform} {self.platform_hash}.",
                            exc_info=True,
                        )
                else:
                    getLogger().error(
                        f"Ignoring unsupported profiler setting: {profiler}: {profiling_types}.",
                    )

        # Run without profiling
        return self._runBinaryBenchmark(cmd, log_to_screen_only, **platform_args)