Skip to content

Instantly share code, notes, and snippets.

@jtallieu
Created March 5, 2017 02:48
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jtallieu/117fb86525cbcfd6e9f2a4957001565f to your computer and use it in GitHub Desktop.
Save jtallieu/117fb86525cbcfd6e9f2a4957001565f to your computer and use it in GitHub Desktop.
Plotter library function to graph Gevent benchmarks with Plotly
import plotly.plotly as py
from plotly import tools
from plotly.graph_objs import *
from plotly.offline import plot
from numpy import *
# Make a gradient pattern of 12 colors.
N = 12
colors = ['hsl('+str(h)+',50%'+',50%)' for h in linspace(0, 360, N)]
def graph_ops(filename, data, offline=True):
traces = []
for count, series in enumerate(data['series']):
traces.append(Bar(
name="{} ops".format(series['name']),
y = [series['name']],
x = [series['total_ops']],
orientation='h',
marker=dict(color=colors[count])
))
layout = Layout(
title=data['title'],
legend=dict(bordercolor="#444", bgcolor="#eee", borderwidth=1),
margin=dict(b=100, l=150, t=80, r=150),
yaxis=dict(
title="Number of Greenlets",
type="category",
showline=True,
showgrid=True,
),
xaxis=dict(title="Total Operations", showline=True)
)
fig = Figure(data=traces, layout=layout)
if offline:
print plot(fig, filename=filename, auto_open=False, show_link=True)
else:
print py.plot(fig, filename=filename, auto_open=False, show_link=True)
def graph_latency(filename, data, offline=True):
traces = []
for count, series in enumerate(data['series']):
traces.append(Box(
x = series['data'],
name = series['name'],
boxmean = True,
marker=dict(color=colors[count])
))
layout = Layout(
title=data['title'],
legend=dict(bordercolor="#444", bgcolor="#eee", borderwidth=1),
margin=dict(b=100, l=150, t=80, r=150),
yaxis=dict(
title="Number of Greenlets",
type="category",
showline=True,
showgrid=True,
),
xaxis=dict(title="Latency (seconds)", showline=True)
)
fig = Figure(data=traces, layout=layout)
if offline:
print plot(fig, filename=filename, auto_open=False, show_link=True)
else:
print py.plot(fig, filename=filename, auto_open=False, show_link=True)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment