src/tools/benchmark_tool/benchmark_tool/metric/average_metric.py
def compute_metric(self, reportMsg=""):
        """
        Start the computation of the metric.

        It reads the file that shall contain one value for each line, computes the average and
        creates a new file with the minimum value, the average and the maximum value in this order.

        @param reportMsg: The message to print. It must have three %f fields for min, average and
            max value, in this order.
        @return: True on success, False on failure
        """
        filename = self._result_folder + "/" + self._result_file_name

        if os.path.isfile(filename):
            # Compute the average
            try:
                file = open(filename, "r")
                file_lines = file.readlines()
            except Exception as e:
                error(self.node, "%s" % str(e))
                return False
            finally:
                file.close()

            av_value = 0.0
            min_value = float("inf")
            max_value = -float("inf")

            for val in file_lines:

                val = float(val.strip("\n"))

                if val < min_value:
                    min_value = val

                if val > max_value:
                    max_value = val

                av_value += val

            av_value = av_value / len(file_lines)

            # Display summary in milliseconds
            min_value /= 1e3
            av_value /= 1e3
            max_value /= 1e3

            if not self._save_metric_file(min_value, av_value, max_value):
                error(self.node, "Error saving metric file.")

            # Print average to the node output
            if("" == reportMsg):
                reportMsg = "metric : \nMin: %.3f\nAverage: %.3f \nMax: %.3f"
            info(self.node,
                 reportMsg % (min_value, av_value, max_value))

        return True

        Start the computation of the metric.

        It reads the file that shall contain one value for each line, computes the average and
        creates a new file with the minimum value, the average and the maximum value in this order.

        @param reportMsg: The message to print. It must have three %f fields for min, average and
            max value, in this order.
        @return: True on success, False on failure
        
Start the computation of the metric.
It reads the file that shall contain one value for each line, computes the average and
creates a new file with the minimum value, the average and the maximum value in this order.
Start the computation of the metric . It reads the file that shall contain one value for each line computes the average and creates a new file with the minimum value the average and the maximum value in this order .
def compute_metric(self, reportMsg=""):
        filename = self._result_folder + "/" + self._result_file_name
        if os.path.isfile(filename):
            try:
                file = open(filename, "r")
                file_lines = file.readlines()
            except Exception as e:
                error(self.node, "%s" % str(e))
                return False
            finally:
                file.close()
            av_value = 0.0
            min_value = float("inf")
            max_value = -float("inf")
            for val in file_lines:
                val = float(val.strip("\n"))
                if val < min_value:
                    min_value = val
                if val > max_value:
                    max_value = val
                av_value += val
            av_value = av_value / len(file_lines)
            min_value /= 1e3
            av_value /= 1e3
            max_value /= 1e3
            if not self._save_metric_file(min_value, av_value, max_value):
                error(self.node, "Error saving metric file.")
            if("" == reportMsg):
                reportMsg = "metric : \nMin: %.3f\nAverage: %.3f \nMax: %.3f"
            info(self.node,
                 reportMsg % (min_value, av_value, max_value))
        return True
def compute_metric ( self , reportMsg = "" ) : filename = self . _result_folder + "/" + self . _result_file_name if os . path . isfile ( filename ) : try : file = open ( filename , "r" ) file_lines = file . readlines ( ) except Exception as e : error ( self . node , "%s" % str ( e ) ) return False finally : file . close ( ) av_value = 0.0 min_value = float ( "inf" ) max_value = - float ( "inf" ) for val in file_lines : val = float ( val . strip ( "\n" ) ) if val < min_value : min_value = val if val > max_value : max_value = val av_value += val av_value = av_value / len ( file_lines ) min_value /= 1e3 av_value /= 1e3 max_value /= 1e3 if not self . _save_metric_file ( min_value , av_value , max_value ) : error ( self . node , "Error saving metric file." ) if ( "" == reportMsg ) : reportMsg = "metric : \nMin: %.3f\nAverage: %.3f \nMax: %.3f" info ( self . node , reportMsg % ( min_value , av_value , max_value ) ) return True
Start the computation of the metric.
Start the computation of the metric .
"""
        Start the computation of the metric.

        It reads the file that shall contain one value for each line, computes the average and
        creates a new file with the minimum value, the average and the maximum value in this order.

        @param reportMsg: The message to print. It must have three %f fields for min, average and
            max value, in this order.
        @return: True on success, False on failure
        """ # Compute the average # Display summary in milliseconds # Print average to the node output
True on success, False on failure
True on success False on failure
self
reportMsg
The message to print. It must have three %f fields for min, average and
max value, in this order.
The message to print . It must have three %f fields for min average and max value in this order .