Last active
April 25, 2018 12:24
-
-
Save frgomes/da986b185bf89b716ecd7661d887f911 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import numpy as np | |
def secs(ms): return ms / 1000 | |
header = ['recs','elapsed','cleanse','kvpairs','wdict','wschema','wtable','rdict','rschema','rtable','wcsv'] | |
data = np.loadtxt('metrics.csv', | |
delimiter = ',', | |
dtype = {'names' : ( header ), | |
'formats': ( 'i4','i4','i4','i4','i4','i4','i4','i4','i4','i4','i4' )}) | |
recs = data['recs'] | |
elapsed = list(map(secs, data['elapsed'])) | |
cleanse = list(map(secs, data['cleanse'])) | |
kvpairs = list(map(secs, data['kvpairs'])) | |
wdict = list(map(secs, data['wdict'])) | |
wschema = list(map(secs, data['wschema'])) | |
wtable = list(map(secs, data['wtable'])) | |
rdict = list(map(secs, data['rdict'])) | |
rschema = list(map(secs, data['rschema'])) | |
rtable = list(map(secs, data['rtable'])) | |
wcsv = list(map(secs, data['wcsv'])) | |
## only relevant fields are displayed. | |
legend = ['elapsed','wdict','wtable','rdict','rtable'] | |
stack = np.row_stack( (elapsed, wdict, wtable, rdict, rtable) ) | |
colors = ['#043488', '#265644', '#C80500', '#508111', '#724055'] | |
import matplotlib.pyplot as plt | |
import matplotlib.patches as mpatches | |
plt.plot(recs, elapsed, color = colors[0]) | |
plt.plot(recs, wdict, color = colors[1]) | |
plt.plot(recs, wtable, color = colors[2]) | |
plt.plot(recs, rdict, color = colors[3]) | |
plt.plot(recs, rtable, color = colors[4]) | |
plt.legend([mpatches.Patch(color = colors[0]), | |
mpatches.Patch(color = colors[1]), | |
mpatches.Patch(color = colors[2]), | |
mpatches.Patch(color = colors[3]), | |
mpatches.Patch(color = colors[4])], legend, loc = 'upper left') | |
plt.xlabel('records') | |
plt.ylabel('t(s)') | |
# This assumes you named a folder so that it reflects the intent of the data in it. | |
import os | |
import re | |
parts = re.split('/', os.getcwd()) | |
basename = parts[-1] | |
plt.title('Metrics - ' + basename) | |
plt.savefig('metrics.png') | |
# optionally opens the chart for visualization immediately | |
# plt.show() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
metrics.csv