def munge(title, values): t0, v0 = values[0] start_time = parsetime(t0) ylabel = ' '.join(title.split(' ')).lower() if title.split(' ')[1] != 'spinlock' and \ title.split(' ', 1)[1] in no_scale_per_second_list: seconds = 1 else: t1, v1 = values[1] seconds = (parsetime(t1) - start_time).seconds ylabel += ' per second' if seconds == 0: seconds = 1 # Split the values into a dictionary of y-axis values keyed by the x axis ydata = {} for t, v in sorted(values): if args.abstime: # Build the time series, milliseconds since the epoch x = int(mktime(parsetime(t).timetuple())) * 1000 else: # Build the time series as seconds since the start of the data x = (parsetime(t) - start_time).seconds ydata[x] = float(v) / seconds return ylabel, ydata
def timesort(s): # Sort the timestr via its parsetime() value so that the year gets # added and it properly sorts. Times are only %b %d %H:%M:%S and # may improperly sort if the data crosses a month boundary. t = operator.itemgetter('#time') timestr = t(s) return parsetime(timestr)
def munge_dict(values_dict, abstime): sorted_values = sorted(values_dict, key=timesort) start_time = parsetime(sorted_values[0]['#time']) ret = [] for v in sorted_values: if abstime: # Build the time series, milliseconds since the epoch v['#time'] = int(mktime(parsetime(v['#time']).timetuple())) * 1000 else: # Build the time series as seconds since the start of the data v['#time'] = (parsetime(v['#time']) - start_time).seconds next_val = {} for title, value in v.items(): if title.find('uS') != -1: title = title.replace('uS', 'ms') value = float(value) / 1000 if title == 'totalsec': value = 0 if title == 'checkpoints' and value == 'N': value = 0 elif title.find('time') != -1: title = 'time' elif title.find('latency') == -1 and \ title.find('checkpoints') == -1: title = title + ' (thousands)' value = float(value) / 1000 next_val[title] = value ret.append(next_val) # After building the series, eliminate constants d0 = ret[0] for t0, v0 in d0.items(): skip = True for d in ret: v = d[t0] if v != v0: skip = False break if skip: for dicts in ret: del dicts[t0] return ret
def munge_dict(values_dict, abstime): sorted_values = sorted(values_dict, key=timesort) start_time = parsetime(sorted_values[0]["#time"]) ret = [] for v in sorted_values: if abstime: # Build the time series, milliseconds since the epoch v["#time"] = int(mktime(parsetime(v["#time"]).timetuple())) * 1000 else: # Build the time series as seconds since the start of the data v["#time"] = (parsetime(v["#time"]) - start_time).seconds next_val = {} for title, value in v.items(): if title.find("uS") != -1: title = title.replace("uS", "ms") value = float(value) / 1000 if title == "totalsec": value = 0 if title == "checkpoints" and value == "N": value = 0 elif title.find("time") != -1: title = "time" elif title.find("latency") == -1 and title.find("checkpoints") == -1: title = title + " (thousands)" value = float(value) / 1000 next_val[title] = value ret.append(next_val) # After building the series, eliminate constants d0 = ret[0] for t0, v0 in d0.items(): skip = True for d in ret: v = d[t0] if v != v0: skip = False break if skip: for dicts in ret: del dicts[t0] return ret
def munge(title, values): t0, v0 = values[0] start_time = parsetime(t0) ylabel = ' '.join(title.split(' ')).lower() if title.split(' ')[1] != 'spinlock' and \ title.split(' ', 1)[1] in no_scale_per_second_list: seconds = 1 else: t1, v1 = values[1] seconds = (parsetime(t1) - start_time).seconds ylabel += ' per second' if seconds == 0: seconds = 1 stats_cleared = False if args.clear or title.split(' ', 1)[1] in no_clear_list: stats_cleared = True # Split the values into a dictionary of y-axis values keyed by the x axis ydata = {} last_value = 0.0 for t, v in sorted(values): if args.abstime: # Build the time series, milliseconds since the epoch x = int(mktime(parsetime(t).timetuple())) * 1000 else: # Build the time series as seconds since the start of the data x = (parsetime(t) - start_time).seconds float_v = float(v) if not stats_cleared: float_v = float_v - last_value # Sometimes WiredTiger stats go backwards without clear, assume # that means nothing happened if float_v < 0: float_v = 0.0 last_value = float(v) ydata[x] = float_v / seconds return ylabel, ydata