Exemplo n.º 1
0
def compchart_2dbarchart_jsonlogdata(settings, dataset):
    """This function is responsible for creating bar charts that compare data."""

    dataset_types = shared.get_dataset_types(dataset)
    data = shared.get_record_set_improved(settings, dataset, dataset_types)

    # pprint.pprint(data)

    fig, (ax1, ax2) = plt.subplots(nrows=2,
                                   gridspec_kw={'height_ratios': [7, 1]})
    ax3 = ax1.twinx()
    fig.set_size_inches(10, 6)

    #
    # Puts in the credit source (often a name or url)
    if settings['source']:
        plt.text(1,
                 -0.08,
                 str(settings['source']),
                 ha='right',
                 va='top',
                 transform=ax1.transAxes,
                 fontsize=9)

    ax2.axis('off')

    return_data = create_bars_and_xlabels(settings, data, ax1, ax3)
    rects1 = return_data['rects1']
    rects2 = return_data['rects2']
    ax1 = return_data['ax1']
    ax3 = return_data['ax3']
    #
    # Set title
    settings['type'] = ""
    settings['iodepth'] = dataset_types['iodepth']
    if settings['rw'] == 'randrw':
        supporting.create_title_and_sub(settings, plt, skip_keys=['iodepth'])
    else:
        supporting.create_title_and_sub(settings, plt, skip_keys=[])

    #
    # Labeling the top of the bars with their value
    shared.autolabel(rects1, ax1)
    shared.autolabel(rects2, ax3)

    shared.create_stddev_table(settings, data, ax2)

    if settings['show_cpu']:
        shared.create_cpu_table(settings, data, ax2)

    # Create legend
    ax2.legend((rects1[0], rects2[0]),
               (data['y1_axis']['format'], data['y2_axis']['format']),
               loc='center left',
               frameon=False)

    #
    # Save graph to PNG file
    #
    supporting.save_png(settings, plt, fig)
Exemplo n.º 2
0
def compchart_2dbarchart_jsonlogdata(settings, dataset):
    """This function is responsible for creating bar charts that compare data."""

    dataset_types = shared.get_dataset_types(dataset)
    data = shared.get_record_set_improved(settings, dataset, dataset_types)

    # pprint.pprint(data)

    fig, (ax1, ax2) = plt.subplots(nrows=2,
                                   gridspec_kw={"height_ratios": [7, 1]})
    ax3 = ax1.twinx()
    fig.set_size_inches(10, 6)

    #
    # Puts in the credit source (often a name or url)
    supporting.plot_source(settings, plt, ax1)
    supporting.plot_fio_version(settings, data["fio_version"][0], plt, ax1)

    ax2.axis("off")

    return_data = create_bars_and_xlabels(settings, data, ax1, ax3)
    rects1 = return_data["rects1"]
    rects2 = return_data["rects2"]
    ax1 = return_data["ax1"]
    ax3 = return_data["ax3"]
    #
    # Set title
    settings["type"] = ""
    settings["iodepth"] = dataset_types["iodepth"]
    if settings["rw"] == "randrw":
        supporting.create_title_and_sub(settings, plt, skip_keys=["iodepth"])
    else:
        supporting.create_title_and_sub(settings, plt, skip_keys=[])

    #
    # Labeling the top of the bars with their value
    shared.autolabel(rects1, ax1)
    shared.autolabel(rects2, ax3)

    tables.create_stddev_table(settings, data, ax2)

    if settings["show_cpu"] and not settings["show_ss"]:
        tables.create_cpu_table(settings, data, ax2)

    if settings["show_ss"] and not settings["show_cpu"]:
        tables.create_steadystate_table(settings, data, ax2)

    # Create legend
    ax2.legend(
        (rects1[0], rects2[0]),
        (data["y1_axis"]["format"], data["y2_axis"]["format"]),
        loc="center left",
        frameon=False,
    )

    #
    # Save graph to PNG file
    #
    supporting.save_png(settings, plt, fig)
Exemplo n.º 3
0
def chart_2dbarchart_jsonlogdata(settings, dataset):
    """This function is responsible for drawing iops/latency bars for a
    particular iodepth."""
    dataset_types = shared.get_dataset_types(dataset)
    data = shared.get_record_set(settings, dataset, dataset_types,
                                 settings['rw'], settings['numjobs'])

    fig, (ax1, ax2) = plt.subplots(
        nrows=2, gridspec_kw={'height_ratios': [7, 1]})
    ax3 = ax1.twinx()
    fig.set_size_inches(10, 6)

    if settings['source']:
        plt.text(1, -0.08, str(settings['source']), ha='right', va='top',
                 transform=ax1.transAxes, fontsize=9)

    ax2.axis('off')
    #
    # Creating the bars and chart
    x_pos = np.arange(0, len(data['x_axis']) * 2, 2)
    width = 0.9

    n = np.array(data['y2_axis']['data'], dtype=float)

    rects1 = ax1.bar(x_pos, data['y1_axis']['data'], width,
                     color='#a8ed63')
    rects2 = ax3.bar(x_pos + width, n, width,
                     color='#34bafa')

    #
    # Configure axis labels and ticks
    ax1.set_ylabel(data['y1_axis']['format'])
    ax1.set_xlabel(data['x_axis_format'])
    ax3.set_ylabel(data['y2_axis']['format'])

    ax1.set_xticks(x_pos + width / 2)
    ax1.set_xticklabels(data['x_axis'])
    #
    # Set title
    settings['type'] = ""
    settings['iodepth'] = dataset_types['iodepth']
    if settings['rw'] == 'randrw':
        supporting.create_title_and_sub(settings, plt, skip_keys=['iodepth'])
    else:
        supporting.create_title_and_sub(
            settings, plt, skip_keys=['iodepth', 'filter'])
    #
    # Labeling the top of the bars with their value
    shared.autolabel(rects1, ax1)
    shared.autolabel(rects2, ax3)
    #
    #
    shared.create_stddev_table(data, ax2)
    #
    # Create legend
    ax2.legend((rects1[0], rects2[0]),
               (data['y1_axis']['format'],
                data['y2_axis']['format']), loc='center left', frameon=False)
    #
    # Save graph to file
    #
    now = datetime.now().strftime('%Y-%m-%d_%H%M%S')
    title = settings['title'].replace(" ", '-')
    title = title.replace("/", '-')
    plt.tight_layout(rect=[0, 0, 1, 0.95])
    fig.savefig(f"{title}_{now}.png", dpi=settings['dpi'])
Exemplo n.º 4
0
def plot_3d(settings, dataset):
    """This function is responsible for plotting the entire 3D plot.
    """

    if not settings['type']:
        print("The type of data must be specified with -t (iops/lat).")
        exit(1)
    if len(settings['type']) != 1:
        print("Expected single type of data to be specified with -t (iops/lat).")
        exit(1)

    dataset_types = shared.get_dataset_types(dataset)
    metric = settings['type'][0]
    rw = settings['rw']
    iodepth = dataset_types['iodepth']
    numjobs = dataset_types['numjobs']
    data = shared.get_record_set_3d(settings, dataset, dataset_types,
                                    rw, metric)
    # pprint.pprint(data)

    fig = plt.figure()
    ax1 = fig.add_subplot(111, projection=Axes3D.name)
    fig.set_size_inches(15, 10)

    lx = len(iodepth)
    ly = len(numjobs)

    # Ton of code to scale latency
    if metric == 'lat':
        scale_factors = []
        for row in data['values']:
            scale_factor = supporting.get_scale_factor(row)
            scale_factors.append(scale_factor)
        largest_scale_factor = supporting.get_largest_scale_factor(
            scale_factors)
        # pprint.pprint(largest_scale_factor)

        scaled_values = []
        for row in data['values']:
            result = supporting.scale_yaxis_latency(
                row, largest_scale_factor)
            scaled_values.append(result['data'])
        z_axis_label = largest_scale_factor['label']
    else:
        scaled_values = data['values']
        z_axis_label = metric

    n = np.array(scaled_values, dtype=float)

    size = lx * 0.05  # thickness of the bar
    xpos_orig = np.arange(0, lx, 1)
    ypos_orig = np.arange(0, ly, 1)

    xpos = np.arange(0, lx, 1)
    ypos = np.arange(0, ly, 1)
    xpos, ypos = np.meshgrid(xpos - size / 2, ypos - size / 2)

    # Convert positions to 1D array
    xpos_f = xpos.flatten(order='C')
    ypos_f = ypos.flatten(order='C')
    zpos = np.zeros(lx * ly)

    # Positioning and sizing of the bars
    dx = np.full(lx * ly, size)
    dy = dx.copy()
    dz = n.flatten(order='F')
    values = dz / (dz.max())

    # Create the 3D chart with positioning and colors
    cmap = plt.get_cmap('rainbow', len(values))
    colors = cm.rainbow(values)
    ax1.bar3d(xpos_f, ypos_f, zpos, dx, dy, dz, color=colors)

    # Create the color bar to the right
    norm = mpl.colors.Normalize(vmin=0, vmax=dz.max())
    sm = plt.cm.ScalarMappable(cmap=cmap, norm=norm)
    sm.set_array([])
    res = fig.colorbar(sm, fraction=0.046, pad=0.04)
    res.ax.set_title(z_axis_label)

    # Set tics for x/y axis
    float_x = [float(x) for x in (xpos_orig)]

    ax1.xaxis.set_ticks(float_x)
    ax1.yaxis.set_ticks(ypos_orig)
    ax1.xaxis.set_ticklabels(iodepth)
    ax1.yaxis.set_ticklabels(numjobs)
    ax1.set_zlim(bottom=0)

    # axis labels
    fontsize = 16
    ax1.set_xlabel('iodepth', fontsize=fontsize)
    ax1.set_ylabel('numjobs', fontsize=fontsize)
    ax1.set_zlabel(z_axis_label, fontsize=fontsize)

    [t.set_verticalalignment('center_baseline') for t in ax1.get_yticklabels()]
    [t.set_verticalalignment('center_baseline') for t in ax1.get_xticklabels()]

    ax1.zaxis.labelpad = 25

    tick_label_font_size = 12
    for t in ax1.xaxis.get_major_ticks():
        t.label.set_fontsize(tick_label_font_size)

    for t in ax1.yaxis.get_major_ticks():
        t.label.set_fontsize(tick_label_font_size)

    ax1.zaxis.set_tick_params(pad=10)
    for t in ax1.zaxis.get_major_ticks():
        t.label.set_fontsize(tick_label_font_size)

    # title
    supporting.create_title_and_sub(
        settings, plt, skip_keys=['iodepth', 'numjobs'], sub_x_offset=0.57, sub_y_offset=1.05)

    fig.text(0.75, 0.03, settings['source'])

    plt.tight_layout()
    title = settings['title'].replace(" ", '-').replace("/", '-')
    metric = settings['type'][0]
    name = title + '-3d-' + metric + '-' + str(rw) + '.png'
    if os.path.isfile(name):
        print(f"File '{name}' already exists")
        exit(1)
    fig.savefig(name, dpi=settings['dpi'])
    plt.close('all')
Exemplo n.º 5
0
def plot_3d(settings, dataset):
    """This function is responsible for plotting the entire 3D plot."""

    if not settings["type"]:
        print("The type of data must be specified with -t (iops/lat/bw).")
        exit(1)

    dataset_types = shared.get_dataset_types(dataset)
    metric = settings["type"][0]
    rw = settings["rw"]
    iodepth = dataset_types["iodepth"]
    numjobs = dataset_types["numjobs"]
    data = shared.get_record_set_3d(settings, dataset, dataset_types, rw,
                                    metric)

    fig = plt.figure()
    ax1 = fig.add_subplot(projection="3d", elev=25)
    fig.set_size_inches(15, 10)
    ax1.set_box_aspect((4, 4, 3), zoom=1.2)

    lx = len(dataset_types["iodepth"])
    ly = len(dataset_types["numjobs"])

    # This code is meant to make the 3D chart to honour the maxjobs and
    # the maxdepth command line settings. It won't win any prizes for sure.
    if settings["maxjobs"]:
        numjobs = [x for x in numjobs if x <= settings["maxjobs"]]
        ly = len(numjobs)
    if settings["maxdepth"]:
        iodepth = [x for x in iodepth if x <= settings["maxdepth"]]
        lx = len(iodepth)
    if settings["maxjobs"] or settings["maxdepth"]:
        temp_x = []
        for item in data["values"]:
            if len(temp_x) < len(iodepth):
                temp_y = []
                for record in item:
                    if len(temp_y) < len(numjobs):
                        temp_y.append(record)
                temp_x.append(temp_y)
        data["iodepth"] = iodepth
        data["numjobs"] = numjobs
        data["values"] = temp_x

    # Ton of code to scale latency or bandwidth
    if metric == "lat" or metric == "bw":
        scale_factors = []
        for row in data["values"]:
            if metric == "lat":
                scale_factor = supporting.get_scale_factor_lat(row)
            if metric == "bw":
                scale_factor = supporting.get_scale_factor_bw(row)
            scale_factors.append(scale_factor)
        largest_scale_factor = supporting.get_largest_scale_factor(
            scale_factors)
        # pprint.pprint(largest_scale_factor)

        scaled_values = []
        for row in data["values"]:
            result = supporting.scale_yaxis(row, largest_scale_factor)
            scaled_values.append(result["data"])
        z_axis_label = largest_scale_factor["label"]

    else:
        scaled_values = data["values"]
        z_axis_label = metric

    n = np.array(scaled_values, dtype=float)

    if lx < ly:
        size = ly * 0.03  # thickness of the bar
    else:
        size = lx * 0.05  # thickness of the bar

    xpos_orig = np.arange(0, lx, 1)
    ypos_orig = np.arange(0, ly, 1)

    xpos = np.arange(0, lx, 1)
    ypos = np.arange(0, ly, 1)
    xpos, ypos = np.meshgrid(xpos - (size / lx), ypos - (size * (ly / lx)))

    xpos_f = xpos.flatten()  # Convert positions to 1D array
    ypos_f = ypos.flatten()

    zpos = np.zeros(lx * ly)

    # Positioning and sizing of the bars
    dx = size * np.ones_like(zpos)
    dy = size * (ly / lx) * np.ones_like(zpos)
    dz = n.flatten(order="F")
    values = dz / (dz.max() / 1)

    # Configure max value for z-axis
    if settings["max"]:
        ax1.set_zlim(0, settings["max"])
        cutoff_values = []
        warning = False
        for value in dz:
            if value < settings["max"]:
                cutoff_values.append(value)
            else:
                warning = True
                cutoff_values.append(settings["max"])
        dz = np.array(cutoff_values)
        if warning:
            print("Warning: z-axis values above ")
            warning_text = f"WARNING: values above {settings['max']} have been cutoff"
            fig.text(0.55, 0.85, warning_text)

    # Create the 3D chart with positioning and colors
    cmap = plt.get_cmap("rainbow", xpos.ravel().shape[0])
    colors = cm.rainbow(values)
    ax1.bar3d(xpos_f, ypos_f, zpos, dx, dy, dz, color=colors, zsort="max")

    # Create the color bar to the right
    norm = mpl.colors.Normalize(vmin=0, vmax=dz.max())
    sm = plt.cm.ScalarMappable(cmap=cmap, norm=norm)
    sm.set_array([])
    res = fig.colorbar(sm, fraction=0.046, pad=0.19)
    res.ax.set_title(z_axis_label)

    # Set tics for x/y axis
    float_x = [float(x) for x in (xpos_orig)]

    ax1.w_xaxis.set_ticks(float_x)
    ax1.w_yaxis.set_ticks(ypos_orig)
    ax1.w_xaxis.set_ticklabels(iodepth)
    ax1.w_yaxis.set_ticklabels(numjobs)

    # axis labels
    fontsize = 16
    ax1.set_xlabel("iodepth", fontsize=fontsize)
    ax1.set_ylabel("numjobs", fontsize=fontsize)
    ax1.set_zlabel(z_axis_label, fontsize=fontsize)

    [t.set_verticalalignment("center_baseline") for t in ax1.get_yticklabels()]
    [t.set_verticalalignment("center_baseline") for t in ax1.get_xticklabels()]

    ax1.zaxis.labelpad = 25

    tick_label_font_size = 12
    for t in ax1.xaxis.get_major_ticks():
        t.label.set_fontsize(tick_label_font_size)

    for t in ax1.yaxis.get_major_ticks():
        t.label.set_fontsize(tick_label_font_size)

    ax1.zaxis.set_tick_params(pad=10)
    for t in ax1.zaxis.get_major_ticks():
        t.label.set_fontsize(tick_label_font_size)

    # title
    supporting.create_title_and_sub(
        settings,
        plt,
        skip_keys=["iodepth", "numjobs"],
        sub_x_offset=0.57,
        sub_y_offset=1.15,
    )

    # Source
    if settings["source"]:
        fig.text(0.65, 0.075, settings["source"])
    if not settings["disable_fio_version"]:
        fio_version = data["fio_version"][0]
        fig.text(
            0.05,
            0.075,
            f"Fio version: {fio_version}\nGraph generated by fio-plot",
            fontsize=8,
        )

    #
    # Save graph to PNG file
    #
    supporting.save_png(settings, plt, fig)
Exemplo n.º 6
0
def plot_3d(settings, dataset):
    """This function is responsible for plotting the entire 3D plot.
    """

    if not settings['type']:
        print("The type of data must be specified with -t (iops/lat).")
        exit(1)

    dataset_types = shared.get_dataset_types(dataset)
    metric = settings['type'][0]
    rw = settings['rw']
    iodepth = dataset_types['iodepth']
    numjobs = dataset_types['numjobs']
    data = shared.get_record_set_3d(settings, dataset, dataset_types, rw,
                                    metric)
    # pprint.pprint(data)

    fig = plt.figure()
    ax1 = fig.add_subplot(111, projection='3d')
    fig.set_size_inches(15, 10)

    lx = len(dataset_types['iodepth'])
    ly = len(dataset_types['numjobs'])

    # Ton of code to scale latency
    if metric == 'lat':
        scale_factors = []
        for row in data['values']:
            scale_factor = supporting.get_scale_factor(row)
            scale_factors.append(scale_factor)
        largest_scale_factor = supporting.get_largest_scale_factor(
            scale_factors)
        # pprint.pprint(largest_scale_factor)

        scaled_values = []
        for row in data['values']:
            result = supporting.scale_yaxis_latency(row, largest_scale_factor)
            scaled_values.append(result['data'])
        z_axis_label = largest_scale_factor['label']
    else:
        scaled_values = data['values']
        z_axis_label = metric

    n = np.array(scaled_values, dtype=float)

    size = lx * 0.05  # thickness of the bar
    xpos_orig = np.arange(0, lx, 1)
    ypos_orig = np.arange(0, ly, 1)

    xpos = np.arange(0, lx, 1)
    ypos = np.arange(0, ly, 1)
    xpos, ypos = np.meshgrid(xpos - (size / lx), ypos - (size))

    xpos_f = xpos.flatten()  # Convert positions to 1D array
    ypos_f = ypos.flatten()
    zpos = np.zeros(lx * ly)

    # Positioning and sizing of the bars
    dx = size * np.ones_like(zpos)
    dy = dx.copy()
    dz = n.flatten()
    values = dz / (dz.max() / 1)

    # Create the 3D chart with positioning and colors
    cmap = plt.get_cmap('rainbow', xpos.ravel().shape[0])
    colors = cm.rainbow(values)
    ax1.bar3d(xpos_f, ypos_f, zpos, dx, dy, dz, color=colors)

    # Create the color bar to the right
    norm = mpl.colors.Normalize(vmin=0, vmax=dz.max())
    sm = plt.cm.ScalarMappable(cmap=cmap, norm=norm)
    sm.set_array([])
    res = fig.colorbar(sm, fraction=0.046, pad=0.04)
    res.ax.set_title(z_axis_label)

    # Set tics for x/y axis
    float_x = [float(x) for x in (xpos_orig)]

    ax1.w_xaxis.set_ticks(float_x)
    ax1.w_yaxis.set_ticks(ypos_orig)
    ax1.w_xaxis.set_ticklabels(iodepth)
    ax1.w_yaxis.set_ticklabels(numjobs)

    # axis labels
    fontsize = 16
    ax1.set_xlabel('iodepth', fontsize=fontsize)
    ax1.set_ylabel('numjobs', fontsize=fontsize)
    ax1.set_zlabel(z_axis_label, fontsize=fontsize)

    [t.set_verticalalignment('center_baseline') for t in ax1.get_yticklabels()]
    [t.set_verticalalignment('center_baseline') for t in ax1.get_xticklabels()]

    ax1.zaxis.labelpad = 25

    tick_label_font_size = 12
    for t in ax1.xaxis.get_major_ticks():
        t.label.set_fontsize(tick_label_font_size)

    for t in ax1.yaxis.get_major_ticks():
        t.label.set_fontsize(tick_label_font_size)

    ax1.zaxis.set_tick_params(pad=10)
    for t in ax1.zaxis.get_major_ticks():
        t.label.set_fontsize(tick_label_font_size)

    # title
    supporting.create_title_and_sub(settings,
                                    plt,
                                    skip_keys=['iodepth', 'numjobs'],
                                    sub_x_offset=0.57,
                                    sub_y_offset=1.05)

    fig.text(0.75, 0.03, settings['source'])

    plt.tight_layout()
    now = datetime.now().strftime('%Y-%m-%d_%H%M%S')
    plt.savefig('3d-iops-jobs' + str(settings['rw']) + "-" + str(now) + '.png')
    plt.close('all')
Exemplo n.º 7
0
def chart_2dbarchart_jsonlogdata(settings, dataset):
    """This function is responsible for drawing iops/latency bars for a
    particular iodepth."""
    rw = settings['rw']
    numjobs = settings['numjobs']
    if not numjobs or len(numjobs) != 1:
        print("Expected only single numjob, got: " + str(numjobs))
        exit(1)

    dataset_types = shared.get_dataset_types(dataset)
    data = shared.get_record_set(settings, dataset, dataset_types, rw, numjobs)

    fig, (ax1, ax2) = plt.subplots(nrows=2,
                                   gridspec_kw={'height_ratios': [7, 1]})
    ax3 = ax1.twinx()
    fig.set_size_inches(10, 6)

    if settings['source']:
        plt.text(1,
                 -0.08,
                 str(settings['source']),
                 ha='right',
                 va='top',
                 transform=ax1.transAxes,
                 fontsize=9)

    ax2.axis('off')
    #
    # Creating the bars and chart
    x_pos = np.arange(0, len(data['x_axis']) * 2, 2)
    width = 0.9

    n = np.array(data['y2_axis']['data'], dtype=float)

    rects1 = ax1.bar(x_pos, data['y1_axis']['data'], width, color='#a8ed63')
    rects2 = ax3.bar(x_pos + width, n, width, color='#34bafa')

    #
    # Configure axis labels and ticks
    ax1.set_ylabel(data['y1_axis']['format'])
    ax1.set_xlabel(data['x_axis_format'])
    ax3.set_ylabel(data['y2_axis']['format'])

    ax1.set_xticks(x_pos + width / 2)
    ax1.set_xticklabels(data['x_axis'])
    #
    # Set title
    settings['type'] = ""
    settings['iodepth'] = dataset_types['iodepth']
    if settings['rw'] == 'randrw':
        supporting.create_title_and_sub(settings, plt, skip_keys=['iodepth'])
    else:
        supporting.create_title_and_sub(settings,
                                        plt,
                                        skip_keys=['iodepth', 'filter'])
    #
    # Labeling the top of the bars with their value
    shared.autolabel(rects1, ax1)
    shared.autolabel(rects2, ax3)
    #
    #
    shared.create_stddev_table(data, ax2)
    #
    # Create legend
    ax2.legend((rects1[0], rects2[0]),
               (data['y1_axis']['format'], data['y2_axis']['format']),
               loc='center left',
               frameon=False)
    #
    # Save graph to file
    #
    plt.tight_layout(rect=[0, 0, 1, 0.95])
    title = settings['title'].replace(" ", '-').replace("/", '-')
    name = title + '-graph-lat-iops-' + str(rw) + '-j' + str(
        numjobs[0]) + '.png'
    if os.path.isfile(name):
        print(f"File '{name}' already exists")
        exit(1)
    fig.savefig(name, dpi=settings['dpi'])
Exemplo n.º 8
0
def plot_3d(settings, dataset):
    """This function is responsible for plotting the entire 3D plot.
    """

    if not settings['type']:
        print("The type of data must be specified with -t (iops/lat).")
        exit(1)

    dataset_types = shared.get_dataset_types(dataset)
    metric = settings['type'][0]
    rw = settings['rw']
    iodepth = dataset_types['iodepth']
    numjobs = dataset_types['numjobs']
    data = shared.get_record_set_3d(settings, dataset, dataset_types, rw,
                                    metric)

    fig = plt.figure()
    ax1 = fig.add_subplot(projection='3d', elev=25)
    fig.set_size_inches(15, 10)
    ax1.set_box_aspect((4, 4, 3), zoom=1.2)

    lx = len(dataset_types['iodepth'])
    ly = len(dataset_types['numjobs'])

    # This code is meant to make the 3D chart to honour the maxjobs and
    # the maxdepth command line settings. It won't win any prizes for sure.
    if settings['maxjobs']:
        numjobs = [x for x in numjobs if x <= settings['maxjobs']]
        ly = len(numjobs)
    if settings['maxdepth']:
        iodepth = [x for x in iodepth if x <= settings['maxdepth']]
        lx = len(iodepth)
    if settings['maxjobs'] or settings['maxdepth']:
        temp_x = []
        for item in data['values']:
            if len(temp_x) < len(iodepth):
                temp_y = []
                for record in item:
                    if len(temp_y) < len(numjobs):
                        temp_y.append(record)
                temp_x.append(temp_y)
        data['iodepth'] = iodepth
        data['numjobs'] = numjobs
        data['values'] = temp_x

    # Ton of code to scale latency
    if metric == 'lat':
        scale_factors = []
        for row in data['values']:
            scale_factor = supporting.get_scale_factor(row)
            scale_factors.append(scale_factor)
        largest_scale_factor = supporting.get_largest_scale_factor(
            scale_factors)
        # pprint.pprint(largest_scale_factor)

        scaled_values = []
        for row in data['values']:
            result = supporting.scale_yaxis_latency(row, largest_scale_factor)
            scaled_values.append(result['data'])
        z_axis_label = largest_scale_factor['label']
    else:
        scaled_values = data['values']
        z_axis_label = metric

    n = np.array(scaled_values, dtype=float)

    if lx < ly:
        size = ly * 0.03  # thickness of the bar
    else:
        size = lx * 0.05  # thickness of the bar

    xpos_orig = np.arange(0, lx, 1)
    ypos_orig = np.arange(0, ly, 1)

    xpos = np.arange(0, lx, 1)
    ypos = np.arange(0, ly, 1)
    xpos, ypos = np.meshgrid(xpos - (size / lx), ypos - (size * (ly / lx)))

    xpos_f = xpos.flatten()  # Convert positions to 1D array
    ypos_f = ypos.flatten()

    zpos = np.zeros(lx * ly)

    # Positioning and sizing of the bars
    dx = size * np.ones_like(zpos)
    dy = size * (ly / lx) * np.ones_like(zpos)
    dz = n.flatten(order='F')
    values = dz / (dz.max() / 1)

    # Configure max value for z-axis
    if settings['max']:
        ax1.set_zlim(0, settings['max'])
        cutoff_values = []
        warning = False
        for value in dz:
            if value < settings['max']:
                cutoff_values.append(value)
            else:
                warning = True
                cutoff_values.append(settings['max'])
        dz = np.array(cutoff_values)
        if warning:
            print(f"Warning: z-axis values above ")
            warning_text = f"WARNING: values above {settings['max']} have been cutoff"
            fig.text(0.55, 0.85, warning_text)

    # Create the 3D chart with positioning and colors
    cmap = plt.get_cmap('rainbow', xpos.ravel().shape[0])
    colors = cm.rainbow(values)
    ax1.bar3d(xpos_f, ypos_f, zpos, dx, dy, dz, color=colors, zsort='max')

    # Create the color bar to the right
    norm = mpl.colors.Normalize(vmin=0, vmax=dz.max())
    sm = plt.cm.ScalarMappable(cmap=cmap, norm=norm)
    sm.set_array([])
    res = fig.colorbar(sm, fraction=0.046, pad=0.19)
    res.ax.set_title(z_axis_label)

    # Set tics for x/y axis
    float_x = [float(x) for x in (xpos_orig)]

    ax1.w_xaxis.set_ticks(float_x)
    ax1.w_yaxis.set_ticks(ypos_orig)
    ax1.w_xaxis.set_ticklabels(iodepth)
    ax1.w_yaxis.set_ticklabels(numjobs)

    # axis labels
    fontsize = 16
    ax1.set_xlabel('iodepth', fontsize=fontsize)
    ax1.set_ylabel('numjobs', fontsize=fontsize)
    ax1.set_zlabel(z_axis_label, fontsize=fontsize)

    [t.set_verticalalignment('center_baseline') for t in ax1.get_yticklabels()]
    [t.set_verticalalignment('center_baseline') for t in ax1.get_xticklabels()]

    ax1.zaxis.labelpad = 25

    tick_label_font_size = 12
    for t in ax1.xaxis.get_major_ticks():
        t.label.set_fontsize(tick_label_font_size)

    for t in ax1.yaxis.get_major_ticks():
        t.label.set_fontsize(tick_label_font_size)

    ax1.zaxis.set_tick_params(pad=10)
    for t in ax1.zaxis.get_major_ticks():
        t.label.set_fontsize(tick_label_font_size)

    # title
    supporting.create_title_and_sub(settings,
                                    plt,
                                    skip_keys=['iodepth', 'numjobs'],
                                    sub_x_offset=0.57,
                                    sub_y_offset=1.15)

    # Source
    fig.text(0.65, 0.075, settings['source'])

    plt.tight_layout()
    now = datetime.now().strftime('%Y-%m-%d_%H%M%S')
    plt.savefig('3d-' + str(metric) + '-jobs' + str(settings['rw']) + "-" +
                str(now) + '.png')
    plt.close('all')
Exemplo n.º 9
0
def chart_2dbarchart_jsonlogdata(settings, dataset):
    """This function is responsible for drawing iops/latency bars for a
    particular iodepth."""
    dataset_types = shared.get_dataset_types(dataset)
    data = shared.get_record_set(settings, dataset, dataset_types)

    fig, (ax1, ax2) = plt.subplots(nrows=2,
                                   gridspec_kw={"height_ratios": [7, 1]})
    ax3 = ax1.twinx()
    fig.set_size_inches(10, 6)

    #
    # Puts in the credit source (often a name or url)
    if settings["source"]:
        plt.text(
            1,
            -0.08,
            str(settings["source"]),
            ha="right",
            va="top",
            transform=ax1.transAxes,
            fontsize=9,
        )

    ax2.axis("off")

    return_data = create_bars_and_xlabels(settings, data, ax1, ax3)

    rects1 = return_data["rects1"]
    rects2 = return_data["rects2"]
    ax1 = return_data["ax1"]
    ax3 = return_data["ax3"]

    #
    # Set title
    settings["type"] = ""
    settings[settings["query"]] = dataset_types[settings["query"]]
    if settings["rw"] == "randrw":
        supporting.create_title_and_sub(
            settings,
            plt,
            skip_keys=[settings["query"]],
        )
    else:
        supporting.create_title_and_sub(
            settings,
            plt,
            skip_keys=[settings["query"], "filter"],
        )
    #
    # Labeling the top of the bars with their value
    shared.autolabel(rects1, ax1)
    shared.autolabel(rects2, ax3)
    #
    # Draw the standard deviation table
    tables.create_stddev_table(settings, data, ax2)
    #
    # Draw the cpu usage table if requested
    # pprint.pprint(data)

    if settings["show_cpu"] and not settings["show_ss"]:
        tables.create_cpu_table(settings, data, ax2)

    if settings["show_ss"] and not settings["show_cpu"]:
        tables.create_steadystate_table(settings, data, ax2)

    #
    # Create legend
    ax2.legend(
        (rects1[0], rects2[0]),
        (data["y1_axis"]["format"], data["y2_axis"]["format"]),
        loc="center left",
        frameon=False,
    )
    #
    # Save graph to PNG file
    #
    supporting.save_png(settings, plt, fig)