def parse_result_line(line): """ Function to parse a memtier summary line, returns any non-valid numbers with default value 0.0. :param line: Line to parse (guaranteed by caller to be a valid summary line). :return: Parsed elements as tuples of doubles. """ r_type, throughput, hits, misses, response_time, data_throughput = line.split( ) throughput = StdLib.get_sane_double(throughput) response_time = StdLib.get_sane_double(response_time) data_throughput = StdLib.get_sane_double(data_throughput) if r_type == 'Gets': hits = StdLib.get_sane_double(hits) misses = StdLib.get_sane_double(misses) return { 'Request_Throughput': throughput, 'Hits': hits, 'Misses': misses, 'Response_Time': response_time, 'Data_Throughput': data_throughput } else: return { 'Request_Throughput': throughput, 'Response_Time': response_time, 'Data_Throughput': data_throughput }
def parse_histogram_entry(line): """ Function to parse a memtier histogram line, returns a valid tuple. :param line: Line to parse (guaranteed by caller to be a valid histogram line). :return: Parsed elements as tuples of doubles. """ _, bucket, cdf_until_and_including_bucket = line.split() bucket = StdLib.get_sane_double(bucket) cdf_until_and_including_bucket = StdLib.get_sane_double( cdf_until_and_including_bucket) return bucket, cdf_until_and_including_bucket
def normalize(self, entry, factor): if entry == 'Histogram_GET': print("Not implemented") if entry == 'Histogram_SET': print("Not implemented") if entry == 'GET': if self.get_observed['Request_Throughput'] is not None: multiplier = self.get_observed['Request_Throughput'] / factor for i in [ 'Request_Size', 'Queue_Waiting_Time', 'Memcached_Communication', 'Response_Time' ]: if i in self.get_observed: self.get_observed[ i] = self.get_observed[i] * multiplier if 'Key_Distribution' in self.get_observed.keys( ) and self.get_observed['Key_Distribution'] is not None: self.get_observed['Key_Distribution'] = tuple( StdLib.get_sane_double(x) * multiplier for x in self.get_observed['Key_Distribution']) self.get_interactive['Response_Time'] = self.get_interactive[ 'Response_Time'] * multiplier if entry == 'SET': if self.set_observed['Request_Throughput'] is not None: multiplier = self.set_observed['Request_Throughput'] / factor for i in [ 'Queue_Waiting_Time', 'Memcached_Communication', 'Response_Time' ]: # , 'Queue_Size']: if i in self.set_observed: self.set_observed[ i] = self.set_observed[i] * multiplier self.set_interactive['Response_Time'] = self.set_interactive[ 'Response_Time'] * multiplier
def parse_file(base_path, ping_target): ping_history = [] filename = base_path.joinpath(ping_target + ".ping") # Read in all lines with open(filename, "r") as file: for line in file: splits = line.split('=') if len(splits) > 3: ping_info = splits[3].split() if ping_info[1] == 'ms': ping_history.append( StdLib.get_sane_double(ping_info[0])) elif ping_info[1] == 's': ping_history.append( 1000 * StdLib.get_sane_double(ping_info[0])) else: print("Unexpected unit, got value {} {}", ping_info[0], ping_info[1]) return sum(ping_history) / len(ping_history)