示例#1
0
    def execute_benchmark(self, benchmark_file):
        """
        Execute a single benchmark as defined in a file.
        If called directly, ensure that config and executor attributes are set up.
        @param benchmark_file: the name of a benchmark-definition XML file
        @return: a result value from the executor module
        """
        benchmark = Benchmark(benchmark_file, self.config,
                              self.config.start_time or time.localtime())
        self.check_existing_results(benchmark)

        self.executor.init(self.config, benchmark)
        output_handler = OutputHandler(benchmark, self.executor.get_system_info())

        logging.debug("I'm benchmarking %r consisting of %s run sets.",
                      benchmark_file, len(benchmark.run_sets))

        try:
            result = self.executor.execute_benchmark(benchmark, output_handler)
        finally:
            # remove useless log folder if it is empty
            try:
                os.rmdir(benchmark.log_folder)
            except:
                pass

        if self.config.commit and not self.stopped_by_interrupt:
            try:
                util.add_files_to_git_repository(self.config.output_path,
                        output_handler.all_created_files,
                        self.config.commit_message+'\n\n'+output_handler.description)
            except OSError as e:
                logging.warning('Could not add files to git repository: %s', e)
        return result
示例#2
0
    def execute_benchmark(self, benchmark_file):
        """
        Execute a single benchmark as defined in a file.
        If called directly, ensure that config and executor attributes are set up.
        @param benchmark_file: the name of a benchmark-definition XML file
        @return: a result value from the executor module
        """
        benchmark = Benchmark(
            benchmark_file,
            self.config,
            self.config.start_time or util.read_local_time(),
        )
        self.check_existing_results(benchmark)

        self.executor.init(self.config, benchmark)
        output_handler = OutputHandler(benchmark,
                                       self.executor.get_system_info(),
                                       self.config.compress_results)

        logging.debug(
            "I'm benchmarking %r consisting of %s run sets using %s %s.",
            benchmark_file,
            len(benchmark.run_sets),
            benchmark.tool_name,
            benchmark.tool_version or "(unknown version)",
        )

        try:
            result = self.executor.execute_benchmark(benchmark, output_handler)
        finally:
            benchmark.tool.close()
            output_handler.close()
            # remove useless log folder if it is empty
            try:
                os.rmdir(benchmark.log_folder)
            except OSError:
                pass

        if self.config.commit and not self.stopped_by_interrupt:
            try:
                util.add_files_to_git_repository(
                    self.config.output_path,
                    output_handler.all_created_files,
                    self.config.commit_message + "\n\n" +
                    output_handler.description + "\n\n" +
                    str(output_handler.statistics),
                )
            except OSError as e:
                logging.warning("Could not add files to git repository: %s", e)
        return result