def plot_scal(): import tex tex.setup( width=1, height=None, span=False, l=0.15, r=0.98, t=0.98, b=0.17, params={"hatch.linewidth": 0.5}, ) per_frame_delay_arr = list() for i in range(MAX_COTAINER_NUM): tmp_arr_1 = list() for r in range(NUM_RUN): tmp_arr_2 = list() for j in range(i + 1): csv_path = os.path.join( CSV_FILE_DIR, "%d_%d_%d_yolo_v2_pp_delay.csv" % (i + 1, j + 1, r + 1), ) with open(csv_path, "r") as f: total = f.readlines()[-1].strip().split(":")[1] tmp_arr_2.append(float(total)) tmp_arr_1.append(max(tmp_arr_2) / ((i + 1) * IMAGE_NUM)) per_frame_delay_arr.append(tmp_arr_1[:]) print(per_frame_delay_arr) fig, ax = plt.subplots() x = range(MAX_COTAINER_NUM) x_labels = [a + 1 for a in x] y = [np.average(a) for a in per_frame_delay_arr] yerr = [np.std(a) for a in per_frame_delay_arr] ax.bar( x, y, 0.3, color="blue", lw=0.6, yerr=yerr, ecolor="red", error_kw={"elinewidth": 1}, alpha=0.8, edgecolor="black", ) ax.set_xticks(x) ax.set_xticklabels(x_labels) ax.set_ylabel("Average Inference Delay (ms)") ax.set_xlabel("Number of containers") tex.save_fig(fig, "./scal_yolov2_pp", fmt="png") plt.close(fig)
def plot_bw(): tex.setup(width=1, height=None, span=False, l=0.15, r=0.98, t=0.98, b=0.17, params={'hatch.linewidth': 0.5}) PAYLOAD_SIZE = [256, 512, 1024, 1400] cmap = cm.get_cmap('tab10') csv_names = ['udp_bw_dpdk_fwd_kni_2core.csv', 'udp_bw_xdp_dpdk_fwd.csv'] N = 4 ind = np.arange(N) # the x locations for the groups width = 0.25 # the width of the bars fig, ax = plt.subplots() labels = ["Centralized", "Chain-based"] markers = ['o', 'x', '^'] line_styles = ['dashed', 'solid', '--'] for idx, csv in enumerate(csv_names): csv_path = os.path.join("./bandwidth/results/", csv) bw_arr = np.genfromtxt( csv_path, delimiter=',', usecols=list(range(0, 2))) / 1000.0 bw_avg = bw_arr[:, 1] # bar = ax.bar(ind + idx * width, bw_avg, width, color=cmap(idx), bottom=0, # edgecolor='black', alpha=0.8, lw=0.6, # hatch=hatch_patterns[idx], # label=labels[idx]) # label_bar(bar, ax) ax.plot(ind, bw_avg, color=cmap(STYLE_MAP[labels[idx]]['color']), ls=line_styles[idx], label=labels[idx], marker=markers[idx], markerfacecolor="None", markeredgecolor=cmap(STYLE_MAP[labels[idx]]['color']), ms=3) ax.set_ylabel('Bandwidth (Mbits/sec)') ax.set_xticks(ind) ax.set_xticklabels(('256', '512', '1024', '1400')) ax.set_xlabel('Payload Size (Bytes)') handles, labels = ax.get_legend_handles_labels() ax.legend(handles, labels, loc='upper left') ax.autoscale_view() ax.grid(linestyle='--') save_fig(fig, "./bandwidth")
def plot_shared_x(): """Maybe look nicer""" import tex tex.setup(width=1, height=None, span=False, l=0.15, r=0.98, t=0.98, b=0.17, params={'hatch.linewidth': 0.5}) cmap = plt.get_cmap("tab10") for m in MODELS: fig, ax_arr = plt.subplots(2, sharex=True) ax_arr[0].set_ylabel("Output Size (Bytes)", fontsize=5) ax_arr[1].set_ylabel("Inference Latency (ms)", fontsize=5) x, x_labels, out_s = plot_io_sizes(m, just_return=True) ax_arr[0].bar(x, out_s, BAR_WIDTH, color=cmap(0), lw=0.6, hatch="xxx", alpha=0.8, edgecolor='black') ax_arr[0].axhline(y=(604 * 604 * 3), ls="--", color="green", label="Image Size") x, delay_avg, delay_err = plot_layer_delay(m, just_return=True) ax_arr[1].bar(x, delay_avg, BAR_WIDTH, color=cmap(1), lw=0.6, bottom=0, hatch="+++", yerr=delay_err, ecolor='red', error_kw={"elinewidth": 1}, alpha=0.8, edgecolor='black') ax_arr[1].axhline(y=1000, ls="--", color="green") for ax in ax_arr: ax.set_ylim(0) handles, labels = ax_arr[0].get_legend_handles_labels() ax_arr[0].legend(handles, labels, loc='best') ax_arr[0].autoscale_view() ax_arr[1].set_xticks(x) ax_arr[1].set_xticklabels(x_labels, rotation="vertical") fig.align_ylabels(ax_arr) tex.save_fig(fig, "./combined_%s" % m, fmt="png")
def plot_scal(): import tex tex.setup(width=1, height=None, span=False, l=0.15, r=0.98, t=0.98, b=0.17, params={'hatch.linewidth': 0.5}) IMAGE_NUM = 25 max_cotainer_num = 3 num_run = 2 per_frame_delay_arr = list() for i in range(max_cotainer_num): tmp_arr_1 = list() for r in range(num_run): tmp_arr_2 = list() for j in range(i + 1): with open( "./%d_%d_%d_yolo_v2_pp_delay.csv" % (i + 1, j + 1, r + 1), "r") as f: total = f.readlines()[-1].strip().split(":")[1] tmp_arr_2.append(float(total)) tmp_arr_1.append(max(tmp_arr_2) / ((i + 1) * IMAGE_NUM)) per_frame_delay_arr.append(tmp_arr_1[:]) print(per_frame_delay_arr) fig, ax = plt.subplots() x = range(max_cotainer_num) x_labels = [a + 1 for a in x] y = [np.average(a) for a in per_frame_delay_arr] yerr = [np.std(a) for a in per_frame_delay_arr] ax.bar(x, y, 0.3, color='blue', lw=0.6, yerr=yerr, ecolor='red', error_kw={"elinewidth": 1}, alpha=0.8, edgecolor='black') ax.set_xticks(x) ax.set_xticklabels(x_labels) ax.set_ylabel("Average Inference Delay (ms)") ax.set_xlabel("Number of containers") tex.save_fig(fig, "./scal_yolov2_pp", fmt="png") plt.close(fig)
def plot_io_sizes(m, just_return=False): import tex tex.setup( width=1, height=None, span=False, l=0.15, r=0.98, t=0.98, b=0.17, params={"hatch.linewidth": 0.5}, ) # format: (idx, name, input, output) label_gen = LABEL_GEN() data = list() with open("./net_info_%s.csv" % m, "r") as f: net_infos = f.readlines() for info in net_infos: fields = list(map(str.strip, info.split(","))) fields = list(map(int, info.split(","))) data.append((fields[0], label_gen.get_label(fields[1]), fields[2], fields[3])) x = [i[0] for i in data] x_labels = [i[1] for i in data] out_s = [i[3] for i in data] if just_return: return [x, x_labels, out_s] else: # Plot io_sizes in separate figures fig, ax = plt.subplots() ax.bar( x, out_s, BAR_WIDTH, color="blue", lw=0.6, alpha=0.8, edgecolor="black", label="Output Size", ) # TODO: Improve the looking ax.set_xticks(x) ax.set_title("%s" % m) ax.set_xticklabels(x_labels, rotation="vertical") ax.set_ylim(0, 1.2 * 10**7) ax.set_ylabel("Output Size (Bytes)") tex.save_fig(fig, "./net_info_%s" % m, fmt="png") plt.close(fig)
def plot_ipd(): tex.setup(width=1, height=None, span=False, l=0.15, r=0.98, t=0.98, b=0.17, params={}) ipd_lst = [1, 2, 3, 4, 5, 10, 20] cmap = cm.get_cmap("tab10") techs = [x + "_%sms.csv" for x in ("kern", "dpdkfwd", "dpdkts")] labels = ("Kernel IP Forwarding", "DPDK Forwarding", "DPDK Appending Timestamps") colors = [cmap(x) for x in range(len(techs))] fig, owd_ax = plt.subplots() for tech, label, color in zip(techs, labels, colors): owd_result_lst = calc_owd_lst("./results/owd/ipd_data/", tech, ipd_lst) owd_ax.errorbar( ipd_lst, [t[0] for t in owd_result_lst], yerr=[t[1] for t in owd_result_lst], marker="o", markerfacecolor="None", markeredgewidth=1, markeredgecolor=color, color=color, ecolor="red", label=label, linestyle="--", ) owd_ax.set_ylabel("One Way Delay (ms)") # base_ax.set_xscale('symlog') owd_ax.set_xlabel("Probing Interval (ms)") owd_ax.set_xticks(ipd_lst) handles, labels = owd_ax.get_legend_handles_labels() owd_ax.legend(handles, labels, loc="best") owd_ax.grid(linestyle="--") save_fig(fig, "./ipd")
def plot_ipd(): tex.setup(width=1, height=None, span=False, l=0.15, r=0.98, t=0.98, b=0.17, params={}) ipd_lst = [1, 2, 3, 4, 5, 10, 20] cmap = cm.get_cmap('tab10') techs = [x + '_%sms.csv' for x in ('kern', 'dpdkfwd', 'dpdkts')] labels = ('Kernel IP Forwarding', 'DPDK Forwarding', 'DPDK Appending Timestamps') colors = [cmap(x) for x in range(len(techs))] fig, owd_ax = plt.subplots() for tech, label, color in zip(techs, labels, colors): owd_result_lst = calc_owd_lst('./results/owd/ipd_data/', tech, ipd_lst) owd_ax.errorbar(ipd_lst, [t[0] for t in owd_result_lst], yerr=[t[1] for t in owd_result_lst], marker='o', markerfacecolor='None', markeredgewidth=1, markeredgecolor=color, color=color, ecolor='red', label=label, linestyle='--') owd_ax.set_ylabel('One Way Delay (ms)') # base_ax.set_xscale('symlog') owd_ax.set_xlabel('Probing Interval (ms)') owd_ax.set_xticks(ipd_lst) handles, labels = owd_ax.get_legend_handles_labels() owd_ax.legend(handles, labels, loc='best') owd_ax.grid(linestyle='--') save_fig(fig, './ipd')
def plot_gap_three_compute(): """Plot gap time results on three compute node""" ########## # Calc # ########## min_sf_num = 1 max_sf_num = 10 result_map = dict() test_round = 30 method_tuple = ('ns', 'fn', 'nsrd') base_path = './test_result/three_compute/' for method in method_tuple: srv_num_result = list() for srv_num in range(min_sf_num, max_sf_num + 1): ins_fn = '%s-sfc-ts-ins-%d.csv' % (method, srv_num) ins_csvp = os.path.join(base_path, ins_fn) ins_data = np.genfromtxt(ins_csvp, delimiter=',') if ins_data.shape[0] < test_round: raise RuntimeError( 'Number of test rounds is wrong, path: %s' % ins_csvp ) if ins_data.shape[1] != srv_num + 4: raise RuntimeError( 'Number of timestamps is wrong, path: %s' % ins_csvp ) else: ins_data = _filter_outlier_gap(ins_data) ins_data = ins_data[:test_round, :] print('[DEBUG] Method: %s, srv_num : %d after filter: %d' % ( method, srv_num, ins_data.shape[0])) srv_num_result.append( # MARK: first 'b' - last 'a' np.average(np.subtract(ins_data[:, -2], ins_data[:, -1])) ) result_map[method] = srv_num_result ########## # Plot # ########## tex.setup(width=1, height=None, span=False, l=0.15, r=0.98, t=0.98, b=0.17, params={ 'hatch.linewidth': 0.5 }) method_label_tuple = ('LB', 'LC', 'LBLC') hatch_patterns = ('xxxx', '////', '++++', '*', 'o', 'O', '.') fig, ax = plt.subplots() width = 0.25 colors = [cmap(x) for x in range(len(method_tuple))] for m_idx, method in enumerate(method_tuple): gt_lst = result_map[method] pos = 0 + m_idx * width x = [pos + x for x in range(min_sf_num, max_sf_num + 1)] ax.bar( x, gt_lst, width, alpha=0.8, color=colors[m_idx], edgecolor='black', label=method_label_tuple[m_idx], hatch=hatch_patterns[m_idx], lw=0.6 ) handles, labels = ax.get_legend_handles_labels() ax.legend(handles, labels, loc='best') ax.set_xlabel('Chain length') x = np.arange(min_sf_num, max_sf_num + 1, 1, dtype='int32') ax.set_xticks(x + (width / 2.0) * (len(method_tuple) - 1)) ax.set_xticklabels(x) ax.set_ylabel("Gap duration (s)") ax.yaxis.grid(which='major', lw=0.5, ls='--') save_fig(fig, './sfc_gap_time') fig.show()
def plot_adv_comp_per_packet_delay(payload_size=1400): tex.setup(width=1, height=None, span=False, l=0.15, r=0.98, t=0.98, b=0.17, params={'hatch.linewidth': 0.5}) print("Current payload size: {}B".format(payload_size)) N = 9 if payload_size == 256: N = 9 ind = np.arange(N) width = 0.15 fig, ax = plt.subplots() # Interate different adv functions func_map = { "nc_enc_sliding_window_25_binary8": [0, "NC Sliding Window", "++++", "-", "o"], "nc_enc_noack_25_binary8": [1, "NC Block Code", "xxxx", "--", "x"], "aes_ctr_enc_25_256": [2, "AES256 ENC", "\\\\\\\\", "-.", "+"], "aes_ctr_dec_25_256": [3, "AES256 DEC", "////", ":", "v"], } try: for func, para in func_map.items(): csv_files = list() for i in range(1, N + 1): if payload_size != 1400: csv_files.append("{}_per_packet_delay_{}_{}.csv".format( i, func, payload_size)) else: csv_files.append("{}_per_packet_delay_{}.csv".format( i, func)) delay_map = dict() delay_map_val = list() for csv in csv_files: csv_path = os.path.join("./comp_eval/results/", csv) delay_arr = np.genfromtxt(csv_path, delimiter=',') * 1000.0 delay_arr_tmp = delay_arr[:] / 1000.0 delay_arr = delay_arr.flatten() delay_arr = delay_arr[500:-500] delay_arr = delay_arr[0:50000] if csv == '8_per_packet_delay_aes_ctr_dec_25_256_256.csv': delay_arr = [x for x in delay_arr if x < 20000] delay_map_val.append( (np.average(delay_arr), calc_std_err(delay_arr))) print("{}, data array:{}".format(func, json.dumps(delay_map_val))) vals = delay_map_val[:] ax.bar(ind + para[0] * width, [x[0] for x in vals], width, edgecolor='black', lw=0.6, alpha=0.8, ecolor='black', error_kw={"elinewidth": 1}, hatch=para[2], label=para[1], color=CMAP(para[0]), yerr=[x[1] for x in vals]) # ax.errorbar( # ind, [x[0] for x in vals], color=CMAP(para[0]), ls=para[3], # ecolor="red", yerr=[x[1] for x in vals], label=para[1], marker=para[4], markerfacecolor="None", # markeredgecolor=CMAP(para[0]), ms=3 # ) except Exception as e: print(e) ax.axhline(y=20, ls="--", color='black', lw=1) if payload_size == 256: ax.set_ylim(0, 30) else: # ax.set_yscale('log') ax.set_ylim(1, 100) # yticks = [1, 10, 20, 100] # ax.set_yticks(yticks) ax.set_xlabel("Number of VNF(s)") ax.set_ylabel('Per-packet Processing Delay (us)') # ax.set_xticks(ind) ax.set_xticks(ind + 3 * width / 2.0) ax.set_xticklabels(list(map(str, range(1, N + 1)))) # ax.set_title("Payload size: {} Bytes".format(payload_size)) handles, labels = ax.get_legend_handles_labels() ax.legend(handles, labels, loc='upper left', ncol=2) ax.autoscale_view() ax.grid(ls='--') save_fig(fig, "./adv_comp_eval_{}".format(payload_size), fmt="pdf") save_fig(fig, "./adv_comp_eval_{}".format(payload_size), fmt="png")
def plot_cdf(): """Plot CDF for comparing pure DPDK and DPDK KNI""" tex.setup( width=1, height=None, span=False, l=0.15, r=0.98, t=0.98, b=0.17, params={"hatch.linewidth": 0.5}, ) cmap = cm.get_cmap("tab10") csv_files = list() csv_files.append("udp_rtt_direct_1400B_5ms.csv") csv_files.append("udp_rtt_xdp_dpdk_fwd_256B_5ms.csv") csv_files.append("udp_rtt_xdp_dpdk_fwd_1400B_5ms.csv") csv_files.append("udp_rtt_dpdk_fwd_kni_256B_5ms.csv") csv_files.append("udp_rtt_dpdk_fwd_kni_2vcpu_1400B_5ms.csv") rtt_map = dict() keys = [ "Direct Forwarding", # "Centralized 1 vCPU", "CALVIN 256 B", "CALVIN 1400 B", "Centralized 256 B", "Centralized 1400 B", ] for i, csv_name in enumerate(csv_files): csv_path = os.path.join("./results/rtt/", csv_name) rtt_arr = (np.genfromtxt( csv_path, delimiter=",", usecols=list(range(0, TOTAL_PACK_NUM))) / 1000.0) rtt_arr = rtt_arr[:, WARM_UP_NUM:] rtt_arr = rtt_arr.flatten() if csv_name == "udp_rtt_xdp_dpdk_fwd_256B_5ms.csv": vfunc = np.vectorize(mod_rtt_random) rtt_arr = vfunc(rtt_arr) rtt_arr = rtt_arr[rtt_arr > 0.07] # Calculate avg and cdi avg = np.average(rtt_arr) calc_hwci print("Name: {}, avg: {}, hwci: {}".format(keys[i], np.average(rtt_arr), calc_hwci(rtt_arr))) for q in range(1, 10): print("{} Quantile {}".format(q / 10.0, np.quantile(rtt_arr, q / 10.0))) rtt_map[keys[i]] = rtt_arr[:] # Use histograms to plot a cumulative distribution fig, ax = plt.subplots() for key, value in rtt_map.items(): idx = STYLE_MAP[key]["color"] n, bins, patches = ax.hist( value, N_BINS, density=True, histtype="step", ls=STYLE_MAP[key]["ls"], cumulative=True, label=key, color=cmap(idx), edgecolor=cmap(idx), ) patches[0].set_xy(patches[0].get_xy()[:-1]) # Plot the average value threshold = plt.axvline(x=0.35, color="black", ls="--", ymin=0, ymax=0.75, lw=1) ax.grid(ls="--") keys.insert(3, "Threshold 0.35 ms") custom_lines = [ Line2D([0], [0], color=CMAP(1), ls="-."), Line2D([0], [0], color=CMAP(3), ls="-"), Line2D([0], [0], color=CMAP(2), ls="-"), Line2D([0], [0], color="black", ls="--"), Line2D([0], [0], color=CMAP(4), ls="--"), Line2D([0], [0], color=CMAP(5), ls="--"), ] # ax.legend(custom_lines, keys, loc='upper left', ncol=2) ax.legend(custom_lines, keys, loc="upper left", ncol=2, fontsize=6) # ax.set_xlim(0, 5) ax.set_xscale("log") ax.set_ylabel("Likelihood of Occurrence") ax.set_ylim(0, 1.35) ax.set_xlabel("Round Trip Time (ms)") yticks = [y / 10.0 for y in range(0, 11, 2)] ax.set_yticks(yticks) save_fig(fig, "rtt_cdf_ipd_5ms", "pdf") save_fig(fig, "rtt_cdf_ipd_5ms", "png")
def plot_ipd(payload_size="1400B", profile=""): tex.setup( width=1, height=None, span=False, l=0.15, r=0.98, t=0.98, b=0.17, params={"hatch.linewidth": 0.5}, ) ipd_lst = [5] cmap = cm.get_cmap("tab10") items = [ "xdp_fwd", "xdp_xor", "lk_fwd", "click_fwd", "click_appendts", "click_xor", "dpdk_fwd", "dpdk_appendts", "dpdk_xor", # 'dpdk_fwd_kni' # 'dpdk_nc_b8_ed1', 'dpdk_nc_ed2' ] if payload_size == "1400B": items.remove("xdp_xor") items = list(map(lambda x: x + "_%s" % payload_size, items)) if profile == "bm": csv_files = ["udp_rtt_" + x + "_%sms_bm.csv" for x in items] title = "Bare-mental, Sender UDP Payload size: %s" % payload_size elif profile == "nfv": csv_files = ["udp_rtt_" + x + "_%sms.csv" for x in items] title = "NFV, Sender UDP Payload size: %s" % payload_size xtick_labels = [ "FWD", "XOR", "FWD", "FWD", "ATS", "XOR", "FWD", "ATS", "XOR", # 'FWD' # 'NC1', 'NC2' ] colors = [cmap(x) for x in (0, 0, 1, 2, 2, 2, 3, 3, 3, 4, 4, 4)] hatch_patterns = ( "xx", "xx", "++", "\\\\", "\\\\", "\\\\", "//", "//", "//", "//", "//", ) labels = [""] * len(csv_files) if payload_size == "1400B": xtick_labels = [ "FWD", "FWD", "FWD", "ATS", "XOR", "FWD", "ATS", "XOR", # 'FWD' # 'NC1', 'NC2' ] colors = [cmap(x) for x in (0, 1, 2, 2, 2, 3, 3, 3, 4)] hatch_patterns = ( "xx", "++", "\\\\", "\\\\", "\\\\", "//", "//", "//", "//", "//", ) labels[0] = "XDP" labels[1] = "LKF" labels[2] = "Click" labels[5] = "DPDK" # labels[8] = "DPDK KNI" if payload_size == "256B": xtick_labels = [ "FWD", "XOR", "FWD", "FWD", "ATS", "XOR", "FWD", "ATS", "XOR", # 'NC1', 'NC2' "FWD", ] labels[0] = "XDP" labels[2] = "LKF" labels[3] = "Click" labels[6] = "DPDK" # labels[9] = "DPDK KNI" bar_width = 0.08 gap = 0.03 fig, rtt_ax = plt.subplots() for idx, tech in enumerate(csv_files): try: rtt_result_lst = calc_rtt_lst("./results/rtt/", csv_files[idx], ipd_lst) rtt_bar = rtt_ax.bar( [0 + idx * (bar_width + gap)], [t[0] for t in rtt_result_lst], yerr=[t[1] for t in rtt_result_lst], color=colors[idx], ecolor="red", edgecolor="black", lw=0.6, alpha=0.8, hatch=hatch_patterns[idx], label=labels[idx], width=bar_width, ) label_bar(rtt_bar, rtt_ax) except OSError: continue rtt_ax.set_ylabel("Round Trip Time (ms)") rtt_ax.set_xticks( [0 + x * (bar_width + gap) for x in range(len(csv_files))]) # rtt_ax.set_xticks([0, 0+bar_width+gap]) rtt_ax.set_ylim(0, 0.5) rtt_ax.set_xticklabels(xtick_labels, fontsize=6) rtt_ax.grid(linestyle="--") handles, labels = rtt_ax.get_legend_handles_labels() rtt_ax.legend(handles, labels, loc="upper left") # rtt_ax.set_title(title) save_fig(fig, "./rtt_fix_ipd_%s_%s" % (payload_size, profile), fmt="pdf")
def plot_cdf(): """Plot CDF for comparing pure DPDK and DPDK KNI""" tex.setup(width=1, height=None, span=False, l=0.15, r=0.98, t=0.98, b=0.17, params={ 'hatch.linewidth': 0.5 } ) cmap = cm.get_cmap('tab10') csv_files = list() csv_files.append('udp_rtt_direct_1400B_5ms.csv') # csv_files.append('udp_rtt_dpdk_fwd_kni_1vcpu_1400B_5ms.csv') csv_files.append('udp_rtt_dpdk_fwd_kni_2vcpu_1400B_5ms.csv') # csv_files.append('udp_rtt_dpdk_dpdk_fwd_1400B_5ms.csv') csv_files.append('udp_rtt_xdp_dpdk_fwd_1400B_5ms.csv') rtt_map = dict() keys = [ 'Direct Forwarding', # "Centralized 1 vCPU", "Centralized", "Chain-based" ] for i, csv_name in enumerate(csv_files): csv_path = os.path.join('./results/rtt/', csv_name) rtt_arr = np.genfromtxt(csv_path, delimiter=',', usecols=list(range(0, TOTAL_PACK_NUM))) / 1000.0 rtt_arr = rtt_arr[:, WARM_UP_NUM:] rtt_arr = rtt_arr.flatten() # Calculate avg and cdi avg = np.average(rtt_arr) calc_hwci print("Name: {}, avg: {}, hwci: {}".format(keys[i], np.average(rtt_arr), calc_hwci(rtt_arr))) for q in range(1, 10): print("{} Quantile {}".format(q/10.0, np.quantile(rtt_arr, q/10.0))) rtt_map[keys[i]] = rtt_arr[:] # Use histograms to plot a cumulative distribution fig, ax = plt.subplots() for key, value in rtt_map.items(): idx = STYLE_MAP[key]['color'] n, bins, patches = ax.hist(value, N_BINS, density=True, histtype='step', ls=STYLE_MAP[key]['ls'], cumulative=True, label=key, color=cmap(idx), edgecolor=cmap(idx)) patches[0].set_xy(patches[0].get_xy()[:-1]) # Plot the average value threshold = plt.axvline(x=0.35, color='black', ls='--', ymin=0, ymax=0.75, lw=1) ax.grid(ls='--') keys.append('Threshold 0.35 ms') custom_lines = [Line2D([0], [0], color=CMAP(1), ls='-.'), Line2D([0], [0], color=CMAP(4), ls='--'), Line2D([0], [0], color=CMAP(2), ls='-'), Line2D([0], [0], color='black', ls='--') ] ax.legend(custom_lines, keys, loc='upper left', ncol=2) # ax.set_xlim(0, 5) ax.set_xscale('log') ax.set_ylabel('Likelihood of Occurrence') ax.set_ylim(0, 1.35) ax.set_xlabel('Round Trip Time (ms)') yticks = [y / 10.0 for y in range(0, 11, 2)] ax.set_yticks(yticks) save_fig(fig, 'rtt_cdf_ipd_5ms', 'pdf') save_fig(fig, 'rtt_cdf_ipd_5ms', 'png')
def plot_ipd(payload_size='1400B', profile=''): tex.setup(width=1, height=None, span=False, l=0.15, r=0.98, t=0.98, b=0.17, params={ 'hatch.linewidth': 0.5 } ) ipd_lst = [5] cmap = cm.get_cmap('tab10') items = [ 'xdp_fwd', 'xdp_xor', 'lk_fwd', 'click_fwd', 'click_appendts', 'click_xor', 'dpdk_fwd', 'dpdk_appendts', 'dpdk_xor', # 'dpdk_fwd_kni' # 'dpdk_nc_b8_ed1', 'dpdk_nc_ed2' ] if payload_size == '1400B': items.remove('xdp_xor') items = list(map(lambda x: x+'_%s' % payload_size, items)) if profile == 'bm': csv_files = ['udp_rtt_' + x + '_%sms_bm.csv' for x in items] title = 'Bare-mental, Sender UDP Payload size: %s' % payload_size elif profile == 'nfv': csv_files = ['udp_rtt_' + x + '_%sms.csv' for x in items] title = 'NFV, Sender UDP Payload size: %s' % payload_size xtick_labels = ['FWD', 'XOR', 'FWD', 'FWD', 'ATS', 'XOR', 'FWD', 'ATS', 'XOR', # 'FWD' # 'NC1', 'NC2' ] colors = [cmap(x) for x in (0, 0, 1, 2, 2, 2, 3, 3, 3, 4, 4, 4)] hatch_patterns = ('xx', 'xx', '++', '\\\\', '\\\\', '\\\\', '//', '//', '//', '//', '//') labels = [""] * len(csv_files) if payload_size == '1400B': xtick_labels = ['FWD', 'FWD', 'FWD', 'ATS', 'XOR', 'FWD', 'ATS', 'XOR', # 'FWD' # 'NC1', 'NC2' ] colors = [cmap(x) for x in (0, 1, 2, 2, 2, 3, 3, 3, 4)] hatch_patterns = ('xx', '++', '\\\\', '\\\\', '\\\\', '//', '//', '//', '//', '//') labels[0] = "XDP" labels[1] = "LKF" labels[2] = "Click" labels[5] = "DPDK" # labels[8] = "DPDK KNI" if payload_size == '256B': xtick_labels = ['FWD', 'XOR', 'FWD', 'FWD', 'ATS', 'XOR', 'FWD', 'ATS', 'XOR', # 'NC1', 'NC2' 'FWD' ] labels[0] = "XDP" labels[2] = "LKF" labels[3] = "Click" labels[6] = "DPDK" # labels[9] = "DPDK KNI" bar_width = 0.08 gap = 0.03 fig, rtt_ax = plt.subplots() for idx, tech in enumerate(csv_files): try: rtt_result_lst = calc_rtt_lst( './results/rtt/', csv_files[idx], ipd_lst) rtt_bar = rtt_ax.bar([0 + idx * (bar_width + gap)], [t[0] for t in rtt_result_lst], yerr=[t[1] for t in rtt_result_lst], color=colors[idx], ecolor='red', edgecolor='black', lw=0.6, alpha=0.8, hatch=hatch_patterns[idx], label=labels[idx], width=bar_width) label_bar(rtt_bar, rtt_ax) except OSError: continue rtt_ax.set_ylabel('Round Trip Time (ms)') rtt_ax.set_xticks([0 + x * (bar_width + gap) for x in range(len(csv_files))]) # rtt_ax.set_xticks([0, 0+bar_width+gap]) rtt_ax.set_ylim(0, 0.5) rtt_ax.set_xticklabels(xtick_labels, fontsize=6) rtt_ax.grid(linestyle='--') handles, labels = rtt_ax.get_legend_handles_labels() rtt_ax.legend(handles, labels, loc='upper left') # rtt_ax.set_title(title) save_fig(fig, './rtt_fix_ipd_%s_%s' % (payload_size, profile), fmt='pdf')
def plot_bw(): tex.setup( width=1, height=None, span=False, l=0.15, r=0.98, t=0.98, b=0.17, params={"hatch.linewidth": 0.5}, ) # PAYLOAD_SIZE = [256, 512, 1024, 1400] PAYLOAD_SIZE = [ 256, 256 + 64, 256 + 64 * 2, 512, 512 + 128, 512 + 2 * 128, 512 + 3 * 128, 1024, 1024 + 256, 1024 + 256 * 2, 1024 + 256 * 3, 1400, ] cmap = cm.get_cmap("tab10") csv_names = ["udp_bw_dpdk_fwd_kni_2core.csv", "udp_bw_xdp_dpdk_fwd.csv"] N = len(PAYLOAD_SIZE) ind = np.arange(N) # the x locations for the groups width = 0.25 # the width of the bars fig, ax = plt.subplots() labels = ["Centralized", "CALVIN"] markers = ["o", "x", "^"] line_styles = ["dashed", "solid", "--"] for idx, csv in enumerate(csv_names): csv_path = os.path.join("./bandwidth/results/", csv) bw_arr = ( np.genfromtxt(csv_path, delimiter=",", usecols=list(range(0, 2))) / 1000.0) bw_avg = bw_arr[:, 1] # bar = ax.bar(ind + idx * width, bw_avg, width, color=cmap(idx), bottom=0, # edgecolor='black', alpha=0.8, lw=0.6, # hatch=hatch_patterns[idx], # label=labels[idx]) # label_bar(bar, ax) ax.plot( ind, bw_avg, color=cmap(STYLE_MAP[labels[idx]]["color"]), ls=line_styles[idx], label=labels[idx], marker=markers[idx], markerfacecolor="None", markeredgecolor=cmap(STYLE_MAP[labels[idx]]["color"]), ms=3, ) ax.set_ylabel("Bandwidth (Mbits/sec)") ax.set_xticks(ind) ax.set_xticklabels(list(map(str, PAYLOAD_SIZE)), fontsize=6) ax.set_xlabel("Payload Size (Bytes)") handles, labels = ax.get_legend_handles_labels() ax.legend(handles, labels, loc="upper left") ax.autoscale_view() ax.grid(linestyle="--") save_fig(fig, "./bandwidth")
def plot_udp_owd(mode='l'): """Plot UDP one way delay""" base_path = './test_result/' sf_num_lst = np.arange(1, 11, dtype='int32') # Order important, smaller ones should be plotted latter if mode == 'l': sf_method_tuple = ('lkf', ) alloc_method_tuple = ('ns', 'fn', 'nsrd') ms = ('tab10', ) elif mode == 'p': sf_method_tuple = ('pyf', ) alloc_method_tuple = ('ns', 'fn', 'nsrd') ms = ('Set1', ) elif mode == 'a' or mode == 'as': sf_method_tuple = ('lkf', 'pyf') alloc_method_tuple = ('ns', 'fn', 'nsrd') # ms = ('plasma', 'Set3') ms = ('tab10', 'Set1') cmap_lst = [cm.get_cmap(m) for m in ms] owd_avg_map = dict() owd_hwci_map = dict() test_round = 15 min_num_packs = 5000 warm_up_num = 500 ########## # Clac # ########## for sf_mt in sf_method_tuple: for alloc_mt in alloc_method_tuple: cur_mt = '-'.join((sf_mt, alloc_mt)) print(cur_mt + '\n' + '-' * 30) owd_avg_lst = list() owd_hwci_lst = list() for srv_num in sf_num_lst: print('--- srv_num: %d' % srv_num) csv_name = '%s-owd-%d.csv' % (cur_mt, srv_num) csv_path = os.path.join(base_path, csv_name) # Use pandas df = pd.read_csv(csv_path, error_bad_lines=False, header=None, usecols=range(0, min_num_packs)) data = df.values if data.shape[0] < test_round: print( 'Number of test rounds is wrong! csv: %s, number: %d' % (csv_name, data.shape[0])) tmp_lst = [ np.average(x) * 1000.0 for x in data[:, warm_up_num:] ] tmp_lst = tmp_lst[:test_round] # Filter out Nan nan_idx = list() isnan_result = np.isnan(tmp_lst) for idx, rst in enumerate(tmp_lst): if rst == True: nan_idx.append(idx) if nan_idx: print('Nan detected, nan index:') print(nan_idx) tmp_lst = [value for value in tmp_lst if not np.isnan(value)] if len(tmp_lst) != test_round: print('Nan detected, after filter: %d' % len(tmp_lst)) # Check speicial test round if cur_mt == 'pyf-fn' and srv_num == 9: # import ipdb # ipdb.set_trace() pass # Check outliers tmp_avg = np.average(tmp_lst) tmp_std = np.std(tmp_lst) ol_idx = list() for idx, val in enumerate(tmp_lst): if np.abs(val - tmp_avg) >= 2 * tmp_std: print('Outliers found, csv path:%s, index: %d' % (csv_path, idx)) ol_idx.append(idx) print('Outlier list: %s' % ','.join(map(str, ol_idx))) # Calc avg and hwci owd_avg_lst.append(np.average(tmp_lst)) # owd_hwci_lst.append((T_FACTOR['99-%d' % test_round] * # np.std(tmp_lst)) / np.sqrt(test_round - 1)) owd_hwci_lst.append( # Get T factor with confidence level (stats.t.interval(cfd_level, test_round, loc=0, scale=1)[1] * np.std(tmp_lst)) / np.sqrt(test_round - 1)) # cur_mt is defined in the inner-loop owd_avg_map[cur_mt] = owd_avg_lst owd_hwci_map[cur_mt] = owd_hwci_lst # print(owd_avg_map) # print(owd_hwci_map) ########## # Plot # ########## tex.setup(width=1, height=None, span=False, l=0.15, r=0.98, t=0.98, b=0.17, params={'hatch.linewidth': 0.5}) hatch_patterns = ('xxxx', '////', '++++', '*', 'o', 'O', '.') width = 0.25 label_map = { 'lkf-fn': 'LKF LC', 'lkf-ns': 'LKF LB', 'lkf-nsrd': 'LKF LBLC', 'pyf-fn': 'PyF LC', 'pyf-ns': 'PyF LB', 'pyf-nsrd': 'PyF LBLC' } ax_lst = list() if mode != 'as': fig, ax = plt.subplots() ax_lst.extend([ax, ax]) else: fig, (ax1, ax2) = plt.subplots(1, 2, sharey=True) ax_lst.extend([ax1, ax2]) for sf_idx, sf_mt in enumerate(sf_method_tuple): # change color map here for all_idx, alloc_mt in enumerate(alloc_method_tuple): cur_mt = '-'.join((sf_mt, alloc_mt)) avg_lst = owd_avg_map[cur_mt] err_lst = owd_hwci_map[cur_mt] pos = 0 + all_idx * width x = [pos + x for x in sf_num_lst] ax_lst[sf_idx].bar( x, avg_lst, width, alpha=ALPHA, yerr=err_lst, color=cmap_lst[sf_idx](all_idx), edgecolor='black', lw=0.6, # edgecolor=cmap_lst[sf_idx](all_idx), label=label_map[cur_mt], error_kw=dict(elinewidth=0.8, ecolor='red'), hatch=hatch_patterns[all_idx]) if mode != 'as': ax = ax_lst[0] ax.set_xticks(sf_num_lst + (width / 2.0) * (len(alloc_method_tuple) - 1)) ax.set_xticklabels(sf_num_lst) ax.set_ylabel("OWD (ms)") ax.set_xlabel("Chain length") ax.set_ylim(0, 11) handles, labels = ax.get_legend_handles_labels() ax.legend(handles, labels, loc='upper left') ax.yaxis.grid(which='major', lw=0.5, ls='--') else: for ax in ax_lst: ax.set_xticks(sf_num_lst + (width / 2.0) * (len(alloc_method_tuple) - 1)) ax.set_xticklabels(sf_num_lst) # ax.set_xlabel("Number of chained SFIs", # fontsize=font_size, fontname=font_name) handles, labels = ax.get_legend_handles_labels() ax.legend(handles, labels, loc='upper left') ax.yaxis.grid(which='major', lw=0.5, ls='--') ax = ax_lst[0] ax.set_ylabel("OWD (ms)", fontsize=font_size, fontname=font_name) # Add a shared x label fig.text(0.5, 0.04, 'Chain length', ha='center', fontsize=font_size, fontname=font_name) fig.savefig('one_way_delay_%s.pdf' % mode, pad_inches=0, bbox_inches='tight', dpi=400, format='pdf')
def plot_layer_delay(m, just_return=False): """TODO: Plot pdf instead of average""" import tex tex.setup( width=1, height=None, span=False, l=0.15, r=0.98, t=0.98, b=0.17, params={"hatch.linewidth": 0.5}, ) label_gen = LABEL_GEN() data = list() with open("./per_layer_delay_%s.csv" % m, "r") as f: lines = f.readlines() for l in lines: fields = list(map(str.strip, l.split(","))) fields = list(map(float, fields)) data.append((int(fields[1]), fields[2], fields[3], fields[0])) # Avoid duplicated label idx_layer_map = dict() layer_len = len(set([int(x[0]) for x in data])) x_labels = list() for idx in range(layer_len): label = label_gen.get_label(data[idx][1]) idx_layer_map[idx] = label x_labels.append(label) delay = dict.fromkeys(x_labels) tl = list() for k in delay.keys(): delay[k] = copy.deepcopy(tl) # Calculate delay for d in data: delay[idx_layer_map[d[0]]].append(d[2]) delay_avg = list() delay_err = list() for l in x_labels: delay_avg.append(np.average(delay[l])) delay_err.append(np.std(delay[l])) x = list(set([int(i[0]) for i in data])) if just_return: return [x, delay_avg, delay_err] else: fig, ax = plt.subplots() ax.bar( x, delay_avg, BAR_WIDTH, color="blue", lw=0.6, yerr=delay_err, ecolor="red", error_kw={"elinewidth": 1}, alpha=0.8, edgecolor="black", label="Latency", ) ax.set_xticks(x) ax.set_xticklabels(x_labels, rotation="vertical") ax.set_ylabel("Inference Latency (ms)") ax.set_ylim(0) tex.save_fig(fig, "./per_layer_delay_%s" % m, fmt="png") plt.close(fig)
def plot_ipd(): """Plot tests for inter-packet delay""" base_path = './test_result/three_compute/ipd/' payload_len = 512 test_round = 10 lat_avg_map = dict() lat_hwci_map = dict() ########## # Calc # ########## for sf_num in (0, 1, 10): lat_avg_lst = [] lat_hwci_lst = [] for ipd in (3, 4, 5, 10, 20): send_rate = int(np.ceil(payload_len / (ipd / 1000.0))) cur_rd_avg_lst = list() for rd in range(1, test_round + 1): csv_path = os.path.join( base_path, 'ipd-ns-%s-512-%s-%s.csv' % (send_rate, sf_num, rd)) cur_lat_arr = np.genfromtxt( csv_path, delimiter=',')[INIT_PAC_NUM:, 1] / 1000.0 cur_rd_avg_lst.append(np.average(cur_lat_arr)) lat_avg_lst.append(np.average(cur_rd_avg_lst)) lat_hwci_lst.append( (T_FACTOR['99.9-10'] * np.std(cur_rd_avg_lst)) / np.sqrt(test_round - 1)) warn_three_std(lat_avg_lst) lat_avg_map[sf_num] = lat_avg_lst lat_hwci_map[sf_num] = lat_hwci_lst print('Avg:') for sf_num, lat_lst in lat_avg_map.items(): print('SF number: %d' % sf_num) print(lat_lst) print('HWCI:') for sf_num, lat_lst in lat_hwci_map.items(): print('SF number: %d' % sf_num) print(lat_lst) ########## # Plot # ########## tex.setup(width=1, height=None, span=False, l=0.15, r=0.98, t=0.98, b=0.17, params={}) fig, ax = plt.subplots() x = (3, 4, 5, 10, 20) sf_num_lst = (0, 1, 10) # colors = [cmap(x * 1 / len(sf_num_lst)) for x in range(len(sf_num_lst))] colors = [cmap(x) for x in range(len(sf_num_lst))] for method in ('LKF', ): label_gen = (method + ' ' + appendix for appendix in ('Chain Length = 0', 'Chain Length = 1', 'Chain Length = 10')) for sf_num, color, label in zip( (0, 1, 10), colors, label_gen, ): y = lat_avg_map[sf_num] ax.errorbar(x, y, yerr=lat_hwci_map[sf_num], color=color, label=label, marker='o', markerfacecolor='None', markeredgewidth=1, markeredgecolor=color, ecolor='red', linestyle='--') ax.set_xlabel("Probing interval (ms)", fontsize=font_size, fontname=font_name) ax.axvline(x=4, ymin=0, ymax=14, ls='--', lw=0.4, color='black') ax.set_xticks((2, 3, 4, 5, 10, 20)) ax.set_ylabel("RTT (ms)", fontsize=font_size, fontname=font_name) ax.set_ylim(0, 16) handles, labels = ax.get_legend_handles_labels() ax.legend(handles, labels, fontsize=font_size, loc='upper right') ax.grid(linestyle='--', lw=0.5) save_fig(fig, './ipd_three_compute') fig.show()
def plot_start_three_compute(inc_wait=True): """Plot start time results on three compute nodes""" tex.setup(width=1, height=None, span=False, l=0.15, r=0.98, t=0.98, b=0.17, params={ 'hatch.linewidth': 0.5 }) test_round = 30 ########## # Calc # ########## min_sf_num = 1 max_sf_num = 10 result_map = dict() # key is method method_tuple = ('ns', 'fn', 'nsrd') ts_info_tuple = ( 'SFI launching duration', 'SFI booting duration', # 'SFI reordering duration', 'PC building duration' ) if not inc_wait: ts_info_tuple = ( 'SFI launching duration', 'SFI booting duration', 'PC building duration' ) base_path = './test_result/three_compute/' for method in method_tuple: srv_num_result = list() for srv_num in range(min_sf_num, max_sf_num + 1): ctl_fn = '%s-sfc-ts-ctl-%d.csv' % (method, srv_num) ctl_csvp = os.path.join(base_path, ctl_fn) ctl_data = np.genfromtxt(ctl_csvp, delimiter=',') if ctl_data.shape[0] < test_round: raise RuntimeError( 'Number of test rounds is wrong, path: %s' % ctl_csvp ) ctl_data = ctl_data[:test_round, :] if not inc_wait: srv_num_result.append( [np.average(ctl_data[:, x]) for x in (0, 2, 3)] ) else: srv_num_result.append( [np.average(ctl_data[:, x]) for x in (0, 1, 3)] ) result_map[method] = srv_num_result ########## # Plot # ########## method_label_tuple = ('LB', 'LC', 'LBLC') fig, ax = plt.subplots() # Add some extra space for the second axis at the bottom # fig.subplots_adjust(bottom=0.2) # Move twinned axis ticks and label from top to bottom width = 0.25 x = np.arange(min_sf_num, max_sf_num + 1, 1, dtype='int32') # hatch_typ = [' ', '/', '.'] hatch_patterns = ('xxxx', '////', '++++', 'oooo', '*', 'o', 'O', '.') # MARK: I don't know hot to plot this better... for m_idx, method in enumerate(method_tuple): pos = 0 + m_idx * width result_lst = result_map[method] cmap = cm.get_cmap('tab10') colors = [cmap(x) for x in range(len(ts_info_tuple))] # MARK: Ugly code... for srv_num, ts_tuple in enumerate(result_lst): for t_idx, ts in enumerate(ts_tuple): rect = ax.bar( srv_num + 1 + pos, ts_tuple[t_idx], width, alpha=0.8, bottom=sum(ts_tuple[0:t_idx]), lw=0.6, color=colors[t_idx], edgecolor='black', label=ts_info_tuple[t_idx], hatch=hatch_patterns[t_idx] ) if t_idx == (len(ts_tuple) - 1): autolabel_bar(ax, rect, -10, method_label_tuple[m_idx]) # Add legend if method == method_tuple[0] and srv_num == 0: handles, labels = ax.get_legend_handles_labels() ax.legend(handles, labels, loc='best') ax.set_xlabel("Chain length") ax.axhline(y=-0.005, color='black', linestyle='-', lw=1) # ax.text(0.5, -0.03, 'SFC creation method', # verticalalignment='bottom', horizontalalignment='center', # transform=ax.transAxes, # color='black', fontsize=font_size) ax.spines["bottom"].set_position(("axes", -0.2)) ax.tick_params(axis='x', which='both', length=0) ax.spines["bottom"].set_visible(False) ax.set_xticks(x + (width / 2.0) * (len(method_tuple) - 1)) ax.set_xticklabels(x) # ax.set_xlim(0, 11) ax.set_ylabel("Rendering duration (s)") ax.set_ylim(0, 340) # ax.grid(linestyle='--', lw=0.5) ax.yaxis.grid(which='major', lw=0.5, ls='--') save_fig(fig, './sfc_start_time') fig.show()
About: Plot percentile of latencies of YOLO Pre-processing VNF """ import numpy as np import matplotlib.pyplot as plt from matplotlib.pyplot import cm import sys sys.path.append("../scripts/") CMAP = cm.get_cmap("tab10") if __name__ == "__main__": import tex tex.setup(width=1, height=None, span=False, l=0.15, r=0.98, t=0.98, b=0.17) fig, ax = plt.subplots() x = np.linspace(50, 100, 1000) lines = [ { "color": CMAP(1), "ls": "-", "label": "Total delay (in VM)", "file": "./total_delay_ms_vm.csv", "y": None, } ] for l in lines:
def plot_poll_interval(): slp_lst = [0] slp_lst.extend([10**x for x in range(0, 6)]) # Calc owd_result_lst = list() for slp in slp_lst: tmp_list = list() if slp == 0: csv_name = 'slp30_0_0_%s.csv' % (slp) else: csv_name = 'slp30_10_10_%s.csv' % (slp) csv_path = os.path.join('./results/owd/slp_data', csv_name) owd_arr = np.genfromtxt(csv_path, delimiter=',') / 1000.0 owd_arr = owd_arr[:, WARM_UP_NUM:] tmp_list = np.average(owd_arr, axis=1) owd_result_lst.append( # Average value and confidence interval (np.average(tmp_list), calc_hwci(tmp_list, confidence=0.99))) print(owd_result_lst) # CPU usage cpu_usage_lst = list() for slp in slp_lst[1:]: csv_name = 'cpu30_10_10_%s.csv' % (slp) csv_path = os.path.join('./results/owd/cpu_data', csv_name) cpu_arr = np.genfromtxt(csv_path, delimiter=',', usecols=range(0, 545)) cpu_arr = cpu_arr[:, :-1] tmp_list = np.average(cpu_arr, axis=1) cpu_usage_lst.append( (np.average(tmp_list), calc_hwci(tmp_list, confidence=0.99))) print(cpu_usage_lst) cpu_usage_lst.insert(0, (100.0, 0)) # Plot tex.setup(width=1, height=None, span=False, l=0.15, r=0.98, t=0.98, b=0.17, params={}) fig, base_ax = plt.subplots() owd_ax = base_ax cpu_ax = owd_ax.twinx() x = slp_lst owd_ax.errorbar(x, [t[0] for t in owd_result_lst], yerr=[t[1] for t in owd_result_lst], marker='o', markerfacecolor='None', markeredgewidth=1, markeredgecolor='blue', color='blue', ecolor='red', label='One Way Delay', linestyle='--') owd_ax.set_ylabel('One Way Delay (ms)') cpu_ax.errorbar(x, [t[0] for t in cpu_usage_lst], yerr=[t[1] for t in cpu_usage_lst], marker='o', markerfacecolor='None', markeredgewidth=1, markeredgecolor='green', color='green', ecolor='red', label='CPU Usage', linestyle='--') cpu_ax.set_ylabel('CPU Usage (percent)') base_ax.set_xscale('symlog') base_ax.set_xlabel('Polling Interval (us)') for ax in (owd_ax, cpu_ax): handles, labels = ax.get_legend_handles_labels() ax.legend(handles, labels, loc='best') base_ax.set_yscale('symlog') save_fig(fig, './dpdk_poll_interval')
def plot_plen(): """Plot tests for UDP payload length""" base_path = './test_result/three_compute/plen/' ipd = 4 test_round = 10 sf_num_lst = (0, 1, 10) plen_lst = [2**x * 128 for x in range(0, 5)] print('Payload list: ' + ','.join(map(str, plen_lst))) ########## # Calc # ########## lat_avg_plen = list() lat_hwci_plen = list() for sf_num in sf_num_lst: lat_avg_lst = [] lat_hwci_lst = [] for plen in plen_lst: send_rate = int(np.ceil(plen / (ipd / 1000.0))) cur_rd_avg_lst = list() for rd in range(1, test_round + 1): csv_path = os.path.join( base_path, 'plen-ns-%s-%s-%s-%s.csv' % (send_rate, plen, sf_num, rd)) cur_lat_arr = np.genfromtxt( csv_path, delimiter=',')[INIT_PAC_NUM:, 1] / 1000.0 cur_rd_avg_lst.append(np.average(cur_lat_arr)) lat_avg_lst.append(np.average(cur_rd_avg_lst)) lat_hwci_lst.append( (T_FACTOR['99.9-10'] * np.std(cur_rd_avg_lst)) / np.sqrt(test_round - 1)) warn_three_std(lat_avg_lst) lat_avg_plen.append(lat_avg_lst) lat_hwci_plen.append(lat_hwci_lst) print('Avg:') for idx, lat_lst in enumerate(lat_avg_plen): print('Index number: %d' % idx) print(lat_lst) print('HWCI:') for idx, lat_lst in enumerate(lat_hwci_plen): print('Index number: %d' % idx) print(lat_lst) ########## # Plot # ########## tex.setup(width=1, height=None, span=False, l=0.15, r=0.98, t=0.98, b=0.17, params={'hatch.linewidth': 0.5}) hatch_patterns = ('xxxx', '////', '++++', '****', 'oooo', '....', '.') fig, ax = plt.subplots() width = 0.3 suffix = ['Chain Length = %s' % sf for sf in sf_num_lst] # colors = [cmap(x * 1 / len(sf_num_lst)) for x in range(len(sf_num_lst))] colors = [cmap(x) for x in range(len(sf_num_lst))] for mt_idx, method in enumerate(['LKF']): label_gen = (method + ' ' + suf for suf in suffix) for sf_idx, label, color in zip( (0, 1, 2), label_gen, # ('green', 'blue', 'red')): colors): pos = [0 + sf_idx * width] * len(plen_lst) cur_x = [sf_idx * width + x for x in range(1, 6)] ax.bar(cur_x, lat_avg_plen[sf_idx], yerr=lat_hwci_plen[sf_idx], error_kw=dict(elinewidth=1, ecolor='red'), alpha=0.8, hatch=hatch_patterns[sf_idx], width=width, color=color, ecolor='black', lw=0.6, label=label) ax.set_xticks( [x + (len(sf_num_lst) - 1) * width / 2.0 for x in range(1, 6)]) ax.set_xticklabels(plen_lst, fontsize=font_size, fontname=font_name) ax.set_xlabel('UDP payload size (bytes)') ax.set_ylabel("RTT (ms)", fontsize=font_size, fontname=font_name) ax.set_ylim(0, 14) handles, labels = ax.get_legend_handles_labels() ax.legend(handles, labels, fontsize=font_size, loc='upper right') # ax.grid(linestyle='--', lw=0.5) ax.yaxis.grid(which='major', lw=0.5, ls='--') save_fig(fig, './plen_three_compute') fig.show()