def do_cdfs(options, stats, write_filepath): if not write_filepath: write_filepath = get_output_filepath(options.input) for metric in options.metrics: print("reformatting data...") data = {} for i, g in enumerate(stats['group']): if options.max and i >= options.max: break data[g] = [d[metric] for d in stats['data'][g]["distribution"]] print("plotting CDFs") xmax = round(math.ceil(max(data[stats['group'][0]]))) axis_limits = [0, xmax, 0, 1] if options.minx: axis_limits[0] = options.minx if options.maxx: axis_limits[1] = options.maxx plot.plot('cdf', data, COLORS, axis_limits, metric, "linear", "linear", write_filepath + '_' + metric + '_cdfs', options.write, xlabel=metric_fullname(metric) + ' (miles)', ylabel='fraction of \ncontroller placements', ext=options.ext) if not options.write: plot.show()
def do_cdfs(options, stats, write_filepath): if not write_filepath: write_filepath = get_output_filepath(options.input) for metric in options.metrics: print "reformatting data..." data = {} for i, g in enumerate(stats['group']): if options.max and i >= options.max: break data[g] = [d[metric] for d in stats['data'][g]["distribution"]] print "plotting CDFs" xmax = round(math.ceil(max(data[stats['group'][0]]))) axis_limits = [0, xmax, 0, 1] if options.minx: axis_limits[0] = options.minx if options.maxx: axis_limits[1] = options.maxx plot.plot('cdf', data, COLORS, axis_limits, metric, "linear", "linear", write_filepath + '_' + metric + '_cdfs', options.write, xlabel = metric_fullname(metric) + ' (miles)', ylabel = 'fraction of \ncontroller placements', ext = options.ext) if not options.write: plot.show()
def do_cloud(options, stats, write_filepath, ext=None): assert len(options.metrics) == 2 x_metric, y_metric = options.metrics print("reformatting data...") metrics = [x_metric, y_metric] data = {} for i, g in enumerate(stats['group']): if options.max and i >= options.max: break data[g] = [d for d in stats['data'][g]["distribution"]] print("plotting point cloud") if not write_filepath: write_filepath = get_output_filepath(options.input) # Series may not have values that monotonically decrease by the controller # number, so consider each value when choosing axis extents. extra_margin = 1.02 maxes = {x_metric: [], y_metric: []} for c in stats['group']: for metric in options.metrics: maxes[metric].append(stats['data'][c][metric]['highest']) axes = [ 0, max(maxes[x_metric]) * extra_margin, 0, max(maxes[y_metric]) * extra_margin ] if not ext: ext = options.ext plot.cloud(data, COLORS, axes, "linear", "linear", write_filepath + '_cloud_' + ','.join(options.metrics), options.write, xlabel=metric_fullname(x_metric) + ' (miles)', ylabel=metric_fullname(y_metric) + ' (miles)', ext=ext, x_metric=x_metric, y_metric=y_metric, legend=True) if not options.write: plot.show()
def do_cloud(options, stats, write_filepath, ext = None): assert len(options.metrics) == 2 x_metric, y_metric = options.metrics print "reformatting data..." metrics = [x_metric, y_metric] data = {} for i, g in enumerate(stats['group']): if options.max and i >= options.max: break data[g] = [d for d in stats['data'][g]["distribution"]] print "plotting point cloud" if not write_filepath: write_filepath = get_output_filepath(options.input) # Series may not have values that monotonically decrease by the controller # number, so consider each value when choosing axis extents. extra_margin = 1.02 maxes = {x_metric: [], y_metric: []} for c in stats['group']: for metric in options.metrics: maxes[metric].append(stats['data'][c][metric]['highest']) axes = [0, max(maxes[x_metric]) * extra_margin, 0, max(maxes[y_metric]) * extra_margin] if not ext: ext = options.ext plot.cloud(data, COLORS, axes, "linear", "linear", write_filepath + '_cloud_' + ','.join(options.metrics), options.write, xlabel = metric_fullname(x_metric) + ' (miles)', ylabel = metric_fullname(y_metric) + ' (miles)', ext = ext, x_metric = x_metric, y_metric = y_metric, legend = True) if not options.write: plot.show()
def do_pareto(options, stats, write_filepath): assert len(options.metrics) == 2 x_metric, y_metric = options.metrics print "reformatting data..." data = {} for i, g in enumerate(stats['group']): if options.max and i >= options.max: break data[g] = [d for d in stats['data'][g]["distribution"]] print "plotting point pareto" if not write_filepath: write_filepath = get_output_filepath(options.input) write_filepath += '_pareto_' + ','.join(options.metrics) plot.pareto(data, COLORS, None, "linear", "linear", write_filepath, options.write, xlabel = metric_fullname(x_metric) + ' (miles)', ylabel = metric_fullname(y_metric) + ' (miles)', ext = options.ext, x_metric = x_metric, y_metric = y_metric, min_x = 0, min_y = 0) plot.pareto(data, COLORS, None, "linear", "linear", write_filepath + '_zoom', options.write, xlabel = metric_fullname(x_metric) + ' (miles)', ylabel = metric_fullname(y_metric) + ' (miles)', ext = options.ext, min_x = 0, min_y = 0, x_metric = x_metric, y_metric = y_metric, loc = "lower right") plot.pareto(data, COLORS, None, "linear", "linear", write_filepath + '_norm', options.write, xlabel = metric_fullname(x_metric) + ' (ratio)', ylabel = metric_fullname(y_metric) + ' (ratio)', ext = options.ext, x_metric = x_metric, y_metric = y_metric, # max_x = 1.2, # max_y = 1.2, normalize = True, legend = True, loc = "upper right") if not options.write: plot.show()
# aspect_colors: dict from aspect names to color and marker strings # aspect_fcns: dict from aspect names to fcns to extract their data # aspect_fcns_gen: fcn(stats, metrics) that genreates aspect_fcns # ylabel: fcn to generate ylabel, given metric # (opt) min/max-*: fcn(options) to generate corresponding value PLOT_FCNS = { 'ranges': { 'aspect_colors': { #'highest': 'rx', 'mean': 'bo', 'lowest': 'g+' }, 'aspect_fcns': { #'highest': (lambda g, d, m: d[m]['highest']), 'mean': (lambda g, d, m: d[m]['mean']), 'lowest': (lambda g, d, m: d[m]['lowest']) }, 'ylabel': (lambda m: metric_fullname(m) + " (miles)"), 'ylabel2': (lambda m: metric_fullname(m) + " (ms)"), 'y2_scale_factor': MILES_TO_MS }, 'miles_cost': { 'aspect_colors': { 'miles_cost': 'rx' }, 'aspect_fcns': { 'miles_cost': (lambda g, d, m: d[m]['lowest'] / float(g)) }, 'ylabel': (lambda m: metric_fullname(m) + "\nmiles over cost") }, 'ratios': { 'aspect_colors': { #'highest': 'rx', 'mean': 'bo',
for metric, line in data['lines'].iteritems(): first = line[0] data_copy['lines'][metric] = [d / float(first) for d in line] return data_copy def norm_x(data, k): data_copy = copy.copy(data) data_copy['x'] = [d / float(k) for d in data['x']] return data_copy # Shared ranges data functions ranges_get_data_fcns = { 'base': { 'get_data_fcn': (lambda g, s, af, a, m: plot.ranges_data(s, af, a, m)), 'xlabel': (lambda m: 'number of controllers (k)'), 'ylabel': (lambda m: metric_fullname(m) + " (miles)"), 'min_y': (lambda o: 0.0), 'ylabel2': (lambda m: metric_fullname(m) + " (ms)"), 'max_y': (lambda o: 13000), 'y2_scale_factor': MILES_TO_MS, 'hlines': LATENCY_LINES }, 'base_ylog': { 'get_data_fcn': (lambda g, s, af, a, m: plot.ranges_data(s, af, a, m)), 'xlabel': (lambda m: 'number of controllers (k)'), 'ylabel': (lambda m: metric_fullname(m) + " (miles)"), 'max_y': (lambda o: 13000), 'min_y': (lambda o: 10), 'yscale': 'log', 'ylabel2': (lambda m: metric_fullname(m) + " (ms)"), 'y2_scale_factor': MILES_TO_MS,
def do_pareto(options, stats, write_filepath): assert len(options.metrics) == 2 x_metric, y_metric = options.metrics print "reformatting data..." data = {} for i, g in enumerate(stats['group']): if options.max and i >= options.max: break data[g] = [d for d in stats['data'][g]["distribution"]] print "plotting point pareto" if not write_filepath: write_filepath = get_output_filepath(options.input) write_filepath += '_pareto_' + ','.join(options.metrics) plot.pareto(data, COLORS, None, "linear", "linear", write_filepath, options.write, xlabel=metric_fullname(x_metric) + ' (miles)', ylabel=metric_fullname(y_metric) + ' (miles)', ext=options.ext, x_metric=x_metric, y_metric=y_metric, min_x=0, min_y=0) plot.pareto(data, COLORS, None, "linear", "linear", write_filepath + '_zoom', options.write, xlabel=metric_fullname(x_metric) + ' (miles)', ylabel=metric_fullname(y_metric) + ' (miles)', ext=options.ext, min_x=0, min_y=0, x_metric=x_metric, y_metric=y_metric, loc="lower right") plot.pareto( data, COLORS, None, "linear", "linear", write_filepath + '_norm', options.write, xlabel=metric_fullname(x_metric) + ' (ratio)', ylabel=metric_fullname(y_metric) + ' (ratio)', ext=options.ext, x_metric=x_metric, y_metric=y_metric, # max_x = 1.2, # max_y = 1.2, normalize=True, legend=True, loc="upper right") if not options.write: plot.show()
# aspect_colors: dict from aspect names to color and marker strings # aspect_fcns: dict from aspect names to fcns to extract their data # aspect_fcns_gen: fcn(stats, metrics) that genreates aspect_fcns # ylabel: fcn to generate ylabel, given metric # (opt) min/max-*: fcn(options) to generate corresponding value PLOT_FCNS = { 'ranges': { 'aspect_colors': {#'highest': 'rx', 'mean': 'bo', 'lowest': 'g+'}, 'aspect_fcns': {#'highest': (lambda g, d, m: d[m]['highest']), 'mean': (lambda g, d, m: d[m]['mean']), 'lowest': (lambda g, d, m: d[m]['lowest'])}, 'ylabel': (lambda m: metric_fullname(m) + " (miles)"), 'ylabel2': (lambda m: metric_fullname(m) + " (ms)"), 'y2_scale_factor': MILES_TO_MS }, 'miles_cost': { 'aspect_colors': {'miles_cost': 'rx'}, 'aspect_fcns': {'miles_cost': (lambda g, d, m: d[m]['lowest'] / float(g))}, 'ylabel': (lambda m: metric_fullname(m) + "\nmiles over cost") }, 'ratios': { 'aspect_colors': {#'highest': 'rx', 'mean': 'bo', 'one': 'g+'},