|
| 1 | +#!/usr/bin/env python3 |
| 2 | + |
| 3 | +import argparse |
| 4 | +import json |
| 5 | +import pygal |
| 6 | +from os import path |
| 7 | +from os import walk |
| 8 | +from pygal.style import Style |
| 9 | + |
| 10 | +chartStyle = Style( |
| 11 | + background='transparent', |
| 12 | + plot_background='transparent', |
| 13 | + font_family='googlefont:Montserrat', |
| 14 | + # colors=('#D8365D', '#78365D') |
| 15 | + colors=('#66CC69', '#173361', '#D8365D'), |
| 16 | + # colors=('#66CC69', '#667C69', '#173361', '#D8365D', '#78365D'), |
| 17 | +) |
| 18 | + |
| 19 | +# theme = pygal.style.CleanStyle |
| 20 | +theme = chartStyle |
| 21 | +fill = False |
| 22 | + |
| 23 | + |
| 24 | +def create_quantile_chart(workload, title, y_label, time_series): |
| 25 | + import math |
| 26 | + chart = pygal.XY(style=theme, dots_size=0.5, |
| 27 | + legend_at_bottom=True, |
| 28 | + truncate_legend=37, |
| 29 | + x_value_formatter=lambda x: '{:,.2f} %'.format( |
| 30 | + 100.0 - (100.0 / (10 ** x))), |
| 31 | + show_dots=False, fill=fill, |
| 32 | + stroke_style={'width': 2}, |
| 33 | + print_values=True, print_values_position='top', |
| 34 | + show_y_guides=True, show_x_guides=False) |
| 35 | + chart.title = title |
| 36 | + # chart.stroke = False |
| 37 | + |
| 38 | + chart.human_readable = True |
| 39 | + chart.y_title = y_label |
| 40 | + chart.x_labels = [0.30103, 1, 2, 3] |
| 41 | + |
| 42 | + for label, values, opts in time_series: |
| 43 | + values = sorted((float(x), y) for x, y in values.items()) |
| 44 | + xy_values = [(math.log10(100 / (100 - x)), y) |
| 45 | + for x, y in values if x <= 99.9] |
| 46 | + chart.add(label, xy_values, stroke_style=opts) |
| 47 | + |
| 48 | + chart.render_to_file('%s/%s.svg' % (args.outPath, workload)) |
| 49 | + |
| 50 | + |
| 51 | +def create_bar_chart(workload, title, y_label, x_label, data): |
| 52 | + chart = pygal.Bar( |
| 53 | + style=theme, dots_size=1, show_dots=False, stroke_style={'width': 2}, fill=fill, |
| 54 | + show_legend=False, show_x_guides=False, show_y_guides=False, print_values_position='top', |
| 55 | + print_values=True, show_y_labels=True, show_x_labels=True, |
| 56 | + ) |
| 57 | + chart.title = title |
| 58 | + chart.x_labels = x_label |
| 59 | + chart.y_title = y_label |
| 60 | + chart.value_formatter = lambda y: "{:,.0f}".format(y) |
| 61 | + |
| 62 | + for label, points in data.items(): |
| 63 | + chart.add(label, points) |
| 64 | + print("workload", workload) |
| 65 | + chart.render_to_file('%s/%s.svg' % (args.outPath, workload)) |
| 66 | + |
| 67 | + |
| 68 | +# chart.render_to_file('%s.svg' % workload) |
| 69 | + |
| 70 | +if __name__ == "__main__": |
| 71 | + parser = argparse.ArgumentParser( |
| 72 | + description='Plot Kafka OpenMessaging Benchmark results') |
| 73 | + parser.add_argument('--filePath', dest='filePath', required=True, type=str, |
| 74 | + help='Explicitly specify result files to plot') |
| 75 | + parser.add_argument('--prefix', dest='prefix', help='prefix of filename') |
| 76 | + parser.add_argument('--outPath', dest='outPath', help='out path to save the plot') |
| 77 | + args = parser.parse_args() |
| 78 | + |
| 79 | + aggregate = [] |
| 80 | + |
| 81 | + for (dirpath, dirnames, filenames) in walk(args.filePath): |
| 82 | + for file in filenames: |
| 83 | + file_path = path.join(dirpath, file) |
| 84 | + data = json.load(open(file_path)) |
| 85 | + data['file'] = file |
| 86 | + aggregate.append(data) |
| 87 | + |
| 88 | + opsPerSes = [] |
| 89 | + latencyMap = [] |
| 90 | + |
| 91 | + drivers = [] |
| 92 | + |
| 93 | + pub_rate_avg = {} |
| 94 | + pub_rate_avg["Throughput (MB/s)"] = [] |
| 95 | + |
| 96 | + colors = ['#2a6e3f', '#ee7959', '#ffee6f', '#e94829', '#667C69', '#173361', '#D8365D', '#33A1C9', '#e47690', |
| 97 | + '#FF5733', '#fac03d', "#f091a0"] |
| 98 | + |
| 99 | + # Aggregate across all runs |
| 100 | + count = 0 |
| 101 | + for data in aggregate: |
| 102 | + |
| 103 | + if ('opsPerSes' in data and data['opsPerSes'] is not None): |
| 104 | + opsPerSes.append(data['opsPerSes']) |
| 105 | + |
| 106 | + if ('latencyMap' in data and data['latencyMap'] is not None): |
| 107 | + latencyMap.append(data['latencyMap']) |
| 108 | + |
| 109 | + drivers.append(data['file']) |
| 110 | + |
| 111 | + if ('opsPerSes' in data and data['opsPerSes'] is not None): |
| 112 | + pub_rate_avg["Throughput (MB/s)"].append( |
| 113 | + { |
| 114 | + 'value': data['opsPerSes'], |
| 115 | + 'color': colors[count] |
| 116 | + }) |
| 117 | + count = count + 1 |
| 118 | + |
| 119 | + # Parse plot options |
| 120 | + opts = [] |
| 121 | + for driver in drivers: |
| 122 | + opts.append({}) |
| 123 | + |
| 124 | + # Generate publish rate bar-chart |
| 125 | + svg = f'pika-{args.prefix}-ops' |
| 126 | + print(pub_rate_avg) |
| 127 | + if ("Throughput (MB/s)" in pub_rate_avg and len(pub_rate_avg["Throughput (MB/s)"]) > 0): |
| 128 | + create_bar_chart(svg, 'Cmd Ops', 'Ops/second', |
| 129 | + drivers, pub_rate_avg) |
| 130 | + |
| 131 | + if (len(latencyMap) > 0): |
| 132 | + time_series = zip(drivers, latencyMap, opts) |
| 133 | + svg = f'pika-{args.prefix}-latency-quantile' |
| 134 | + create_quantile_chart(svg, 'Latency Quantiles', |
| 135 | + y_label='Latency (ms)', |
| 136 | + time_series=time_series) |
0 commit comments