def runBenchmark()

in benchmarking/frameworks/oculus/oculus.py [0:0]


    def runBenchmark(self, info, benchmark, platform):
        tests = benchmark["tests"]
        assert len(tests) == 1, (
            "At this point, only one test should "
            + "exist in one benchmark. However, benchmark "
            + "{} doesn't.".format(benchmark["name"])
        )

        model = benchmark["model"]
        test = tests[0]
        assert set({"input_files", "output_files"}).issubset(test.keys())

        assert platform.getType() == "android", "Only android system is supported"
        platform.util.run("root")
        platform.util.run("remount")

        libraries = []
        if "libraries" in model:
            for entry in model["libraries"]:
                target = entry["target"] if "target" in entry else platform.util.dir
                libraries.append(
                    platform.copyFilesToPlatform(entry["location"], target)
                )

        assert "files" in model, "files field is required in model"

        model_file = {f: model["files"][f]["location"] for f in model["files"]}
        model_file = platform.copyFilesToPlatform(model_file)
        input_files = [f["location"] for f in test["input_files"]]
        inputs = platform.copyFilesToPlatform(input_files)
        outputs = [
            os.path.join(platform.getOutputDir(), t["filename"])
            for t in test["output_files"]
        ]
        # Always copy binary to /system/bin/ directory
        program = platform.copyFilesToPlatform(
            info["programs"]["program"]["location"],
            info["programs"]["program"]["dest_path"],
        )
        env_vars = info["programs"]["program"].get("env_variables", "")
        commands = self._composeRunCommand(
            env_vars, program, platform, test, inputs, outputs
        )
        platform.runBenchmark(commands, log_to_screen_only=True)

        target_dir = os.path.join(self.tempdir, "output")
        shutil.rmtree(target_dir, True)
        os.makedirs(target_dir)

        platform.delFilesFromPlatform(model_file)
        platform.delFilesFromPlatform(inputs)
        # Skip deleting the libraries, as they may be used by other binaries
        # platform.delFilesFromPlatform(libraries)
        platform.delFilesFromPlatform(program)
        # output files are removed after being copied back
        output_files = platform.moveFilesFromPlatform(outputs, target_dir)

        json_file = platform.moveFilesFromPlatform(
            os.path.join(platform.getOutputDir(), "report.json"), self.tempdir
        )
        with open(json_file, "r") as f:
            json_content = json.load(f)

        result = {}
        for one_test in json_content:
            for one_entry in one_test:
                type = one_entry["type"]
                value = one_entry["value"]
                unit = one_entry["unit"]
                metric = one_entry["metric"]
                map_key = "{}_{}".format(type, metric)
                if map_key in result:
                    entry = result[map_key]
                    if entry["unit"] is not None and entry["unit"] != unit:
                        getLogger().error(
                            "The unit do not match in different"
                            " test runs {} and {}".format(entry["unit"], unit)
                        )
                        entry["unit"] = None
                    if entry["metric"] is not None and entry["metric"] != metric:
                        getLogger().error(
                            "The metric do not match in "
                            " different test runs {} and {}".format(
                                entry["metric"], metric
                            )
                        )
                        entry["metric"] = None
                    entry["values"].append(value)
                else:
                    result[map_key] = {
                        "type": type,
                        "values": [value],
                        "unit": unit,
                        "metric": metric,
                    }
        # cleanup
        # platform.delFilesFromPlatform(program)
        # for input in test["input"]:
        #     platform.delFilesFromPlatform(input)
        return result, output_files