コード例 #1
0
ファイル: outputhandler.py プロジェクト: lachnerm/benchexec
    def run_set_to_text(self, runSet, finished=False, cputime=0, walltime=0, energy={}):
        lines = []

        # store values of each run
        for run in runSet.runs:
            lines.append(run.resultline)

        lines.append(runSet.simpleLine)

        # write endline into txt_file
        if finished:
            endline = "Run set {0}".format(runSet.index)

            # format time, type is changed from float to string!
            cputime_str = (
                "None"
                if cputime is None
                else util.format_number(cputime, TIME_PRECISION)
            )
            walltime_str = (
                "None"
                if walltime is None
                else util.format_number(walltime, TIME_PRECISION)
            )
            lines.append(
                self.create_output_line(
                    runSet, endline, "done", cputime_str, walltime_str, "-", []
                )
            )

        return "\n".join(lines) + "\n"
コード例 #2
0
ファイル: outputhandler.py プロジェクト: jhensel/benchexec
    def output_after_run(self, run):
        """
        The method output_after_run() prints filename, result, time and status
        of a run to terminal and stores all data in XML
        """

        # format times, type is changed from float to string!
        cputime_str = util.format_number(run.cputime, TIME_PRECISION)
        walltime_str = util.format_number(run.walltime, TIME_PRECISION)

        # format numbers, number_of_digits is optional, so it can be None
        for column in run.columns:
            if column.number_of_digits is not None:

                # if the number ends with "s" or another letter, remove it
                if (not column.value.isdigit()) and column.value[-2:-1].isdigit():
                    column.value = column.value[:-1]

                try:
                    floatValue = float(column.value)
                    column.value = util.format_number(floatValue, column.number_of_digits)
                except ValueError: # if value is no float, don't format it
                    pass

        # store information in run
        run.resultline = self.create_output_line(run.runSet, run.identifier, run.status,
                cputime_str, walltime_str, run.values.get('host'),
                run.columns)
        self.add_values_to_run_xml(run)

        # output in terminal/console
        if USE_COLORS and sys.stdout.isatty(): # is terminal, not file
            statusStr = COLOR_DIC[run.category].format(run.status.ljust(LEN_OF_STATUS))
        else:
            statusStr = run.status.ljust(LEN_OF_STATUS)

        try:
            OutputHandler.print_lock.acquire()

            valueStr = statusStr + cputime_str.rjust(8) + walltime_str.rjust(8)
            if self.benchmark.num_of_threads == 1:
                util.printOut(valueStr)
            else:
                timeStr = time.strftime("%H:%M:%S", time.localtime()) + " "*14
                util.printOut(timeStr + self.format_sourcefile_name(run.identifier, run.runSet) + valueStr)

            # write result in txt_file and XML
            self.txt_file.append(self.run_set_to_text(run.runSet), False)
            self.statistics.add_result(run)

            # we don't want to write this file to often, it can slow down the whole script,
            # so we wait at least 10 seconds between two write-actions
            currentTime = util.read_monotonic_time()
            if currentTime - run.runSet.xml_file.lastModifiedTime > 60:
                run.runSet.xml_file.replace(self._result_xml_to_string(run.runSet.xml))
                run.runSet.xml_file.lastModifiedTime = util.read_monotonic_time()

        finally:
            OutputHandler.print_lock.release()
コード例 #3
0
ファイル: outputhandler.py プロジェクト: jwacalex/benchexec
    def run_set_to_text(self, runSet, finished=False, cputime=0, walltime=0, energy={}):
        lines = []

        # store values of each run
        for run in runSet.runs:
            lines.append(run.resultline)

        lines.append(runSet.simpleLine)

        # write endline into txt_file
        if finished:
            endline = ("Run set {0}".format(runSet.index))

            # format time, type is changed from float to string!
            cputime_str  = "None" if cputime  is None else util.format_number(cputime, TIME_PRECISION)
            walltime_str = "None" if walltime is None else util.format_number(walltime, TIME_PRECISION)
            lines.append(self.create_output_line(runSet, endline, "done", cputime_str,
                             walltime_str, "-", []))

        return "\n".join(lines) + "\n"
コード例 #4
0
    def output_after_run(self, run):
        """
        The method output_after_run() prints filename, result, time and status
        of a run to terminal and stores all data in XML
        """

        # format times, type is changed from float to string!
        cputime_str = util.format_number(run.values.get("cputime"),
                                         TIME_PRECISION)
        walltime_str = util.format_number(run.values.get("walltime"),
                                          TIME_PRECISION)

        # format numbers, number_of_digits is optional, so it can be None
        for column in run.columns:
            if column.number_of_digits is not None:

                # if the number ends with "s" or another letter, remove it
                if (not column.value.isdigit()
                    ) and column.value[-2:-1].isdigit():
                    column.value = column.value[:-1]

                try:
                    floatValue = float(column.value)
                    column.value = util.format_number(floatValue,
                                                      column.number_of_digits)
                except ValueError:  # if value is no float, don't format it
                    pass

        # store information in run
        run.resultline = self.create_output_line(
            run.runSet,
            run.identifier,
            run.status,
            cputime_str,
            walltime_str,
            run.values.get("host"),
            run.columns,
        )
        self.add_values_to_run_xml(run)

        # output in terminal/console
        statusStr = COLOR_DIC[run.category].format(
            run.status.ljust(LEN_OF_STATUS))

        try:
            OutputHandler.print_lock.acquire()

            valueStr = statusStr + cputime_str.rjust(8) + walltime_str.rjust(8)
            if self.benchmark.num_of_threads == 1:
                util.printOut(valueStr)
            else:
                timeStr = time.strftime("%H:%M:%S",
                                        time.localtime()) + " " * 14
                util.printOut(
                    timeStr +
                    self.format_sourcefile_name(run.identifier, run.runSet) +
                    valueStr)

            # write result in txt_file and XML
            self.txt_file.append(run.resultline + "\n", keep=False)
            self.statistics.add_result(run)

            # we don't want to write this file to often, it can slow down the whole script,
            # so we wait at least 10 seconds between two write-actions
            currentTime = time.monotonic()
            if currentTime - run.runSet.xml_file_last_modified_time > 60:
                self._write_rough_result_xml_to_file(run.runSet.xml,
                                                     run.runSet.xml_file_name)
                run.runSet.xml_file_last_modified_time = time.monotonic()

        finally:
            OutputHandler.print_lock.release()

        if self.compress_results:
            log_file_path = os.path.relpath(
                run.log_file, os.path.join(self.benchmark.log_folder,
                                           os.pardir))
            with self.log_zip_lock:
                self.log_zip.write(run.log_file, log_file_path)
            os.remove(run.log_file)
        else:
            self.all_created_files.add(run.log_file)

        if os.path.isdir(run.result_files_folder):
            self.all_created_files.add(run.result_files_folder)
コード例 #5
0
ファイル: outputhandler.py プロジェクト: seahorn/benchexec
    def output_after_run(self, run):
        """
        The method output_after_run() prints filename, result, time and status
        of a run to terminal and stores all data in XML
        """

        # format times, type is changed from float to string!
        cputime_str = util.format_number(run.cputime, TIME_PRECISION)
        walltime_str = util.format_number(run.walltime, TIME_PRECISION)

        # format numbers, number_of_digits is optional, so it can be None
        for column in run.columns:
            if column.number_of_digits is not None:

                # if the number ends with "s" or another letter, remove it
                if (not column.value.isdigit()
                    ) and column.value[-2:-1].isdigit():
                    column.value = column.value[:-1]

                try:
                    floatValue = float(column.value)
                    column.value = util.format_number(floatValue,
                                                      column.number_of_digits)
                except ValueError:  # if value is no float, don't format it
                    pass

        # store information in run
        run.resultline = self.create_output_line(run.runSet, run.identifier,
                                                 run.status, cputime_str,
                                                 walltime_str,
                                                 run.values.get('host'),
                                                 run.columns)
        self.add_values_to_run_xml(run)

        # output in terminal/console
        if USE_COLORS and sys.stdout.isatty():  # is terminal, not file
            statusStr = COLOR_DIC[run.category].format(
                run.status.ljust(LEN_OF_STATUS))
        else:
            statusStr = run.status.ljust(LEN_OF_STATUS)

        try:
            OutputHandler.print_lock.acquire()

            valueStr = statusStr + cputime_str.rjust(8) + walltime_str.rjust(8)
            if self.benchmark.num_of_threads == 1:
                util.printOut(valueStr)
            else:
                timeStr = time.strftime("%H:%M:%S",
                                        time.localtime()) + " " * 14
                util.printOut(
                    timeStr +
                    self.format_sourcefile_name(run.identifier, run.runSet) +
                    valueStr)

            # write result in txt_file and XML
            self.txt_file.append(self.run_set_to_text(run.runSet), False)
            self.statistics.add_result(run)

            # we don't want to write this file to often, it can slow down the whole script,
            # so we wait at least 10 seconds between two write-actions
            currentTime = util.read_monotonic_time()
            if currentTime - run.runSet.xml_file.lastModifiedTime > 60:
                run.runSet.xml_file.replace(
                    self._result_xml_to_string(run.runSet.xml))
                run.runSet.xml_file.lastModifiedTime = util.read_monotonic_time(
                )

        finally:
            OutputHandler.print_lock.release()