def plot_cache(cacheprof, output, interval = 1, terminaltype = "png"): gp = plotutil.gpinit(terminaltype) gp('set output "{0}"'.format(output)) gp.xlabel('elapsed time [s]') gp('set ytics nomirror') gp('set ylabel "count" offset 4') gp('set y2label "cache miss rate [%]" offset -2') gp('set grid xtics noytics noy2tics') gp('set yrange [0:*]') gp('set y2range [0:100]') gp('set y2tic 10') gds = [] cacheref, cachemiss, cachemissrate = [], [], [] for v in cacheprof: cacheref.append(v["cache-references"]) cachemiss.append(v["cache-misses"]) cachemissrate.append((float(v["cache-misses"]) / v["cache-references"]) * 100) xvals = [interval * i for i in range(len(cacheref))] plotprefdict = {"with_" : "lines"} gds.append(Gnuplot.Data(xvals, cacheref, title = "cache reference", axes = "x1y1", **plotprefdict)) gds.append(Gnuplot.Data(xvals, cachemiss, title = "cache miss", axes = "x1y1", **plotprefdict)) gds.append(Gnuplot.Data(xvals, cachemissrate, title = "cache miss rate", axes = "x1y2", **plotprefdict)) gp.plot(*gds) sys.stdout.write("output {0}\n".format(output)) gp.close()
def plot_cpuprof(cpuprof, output, interval=1, terminaltype="png"): gp = plotutil.gpinit(terminaltype) gp('set output "{0}"'.format(output)) gp.xlabel("elapsed time [s]") gp.ylabel("util [%]") gp('set yrange [0:100]') gp('set key outside') gp('set grid front') gp('set style fill pattern 1 border') gd = [] xvals = [interval * i for i in range(len(cpuprof))] piledatas = [[] for i in range(len(keys))] for vals in cpuprof: piledatas[0].append(vals[0]) for i in range(1, len(keys)): piledatas[i].append(piledatas[i - 1][-1] + vals[i]) gd = [] gd.append( Gnuplot.Data(xvals, piledatas[0], with_="filledcurve x1", title=keys[0])) for i in range(1, len(keys)): gd.append( Gnuplot.Data(xvals, piledatas[i], piledatas[i - 1], with_="filledcurve", title=keys[i])) gp.plot(*gd) sys.stdout.write("output {0}\n".format(output)) gp.close()
def plot_tblrefhist(reliddict, refhist, output, terminaltype="png"): rellist = [0] for d in refhist: for k in d: if k not in rellist and k > 3000: rellist.append(k) gp = plotutil.gpinit(terminaltype) gp('set output "{0}"'.format(output)) gp.xlabel("elapsed time [s]") gp.ylabel("count [pages]") # gp('set key outside') gp("set grid front") gp("set style fill pattern 1 border") gd = [] xlen = len(refhist) piledatas = [[] for i in range(len(rellist))] for d in refhist: for i, relid in enumerate(rellist): if i == 0: piledatas[i].append(d.get(relid, 0)) else: piledatas[i].append(piledatas[i - 1][-1] + d.get(relid, 0)) gd = [] for i, relid in enumerate(rellist): if i == 0: gd.append(Gnuplot.Data(range(xlen), piledatas[i], with_="filledcurve x1", title=reliddict[relid])) else: gd.append( Gnuplot.Data(range(xlen), piledatas[i], piledatas[i - 1], with_="filledcurve", title=reliddict[relid]) ) gp.plot(*gd) sys.stdout.write("output {0}\n".format(output)) gp.close()
def plot_cpuprof(cpuprof, output, terminaltype = "png"): gp = plotutil.gpinit(terminaltype) gp('set output "{0}"'.format(output)) gp.xlabel("elapsed time [s]") gp.ylabel("util [%]") gp('set yrange [0:100]') gp('set key outside') gp('set grid front') gp('set style fill pattern 1 border') gd = [] xlen = len(cpuprof) piledatas = [[] for i in range(len(keys))] for vals in cpuprof: piledatas[0].append(vals[0]) for i in range(1, len(keys)): piledatas[i].append(piledatas[i - 1][-1] + vals[i]) gd = [] gd.append(Gnuplot.Data(range(xlen), piledatas[0], with_ = "filledcurve x1", title = keys[0])) for i in range(1, len(keys)): gd.append(Gnuplot.Data(range(xlen), piledatas[i], piledatas[i - 1], with_ = "filledcurve", title = keys[i])) gp.plot(*gd) sys.stdout.write("output {0}\n".format(output)) gp.close()
def init_gnuplot(terminaltype): gp = plotutil.gpinit(terminaltype) gp.xlabel("elapsed time [s]") gp('set grid') if slide and terminaltype == "png": gp('set termoption font "Times-Roman,22"') plotprefdict = {"with_" : "lines lw 2"} else: plotprefdict = {"with_" : "lines"} return gp, plotprefdict
def init_gnuplot(terminaltype): gp = gpinit(terminaltype) gp('set logscale x') gp('set grid') if slide: if "eps" == terminaltype: gp('set termoption font "Times-Roman,28"') plotprefdict = {"with_" : "linespoints lt 1 lw 6" } elif "png" == terminaltype: gp('set termoption font "Times-Roman,16"') plotprefdict = {"with_" : "linespoints lw 2"} else: plotprefdict = {"with_" : "linespoints" } return gp, plotprefdict
def init_gnuplot(terminaltype): gp = gpinit(terminaltype) gp('set logscale x') gp('set grid') if slide: if "eps" == terminaltype: gp('set termoption font "Times-Roman,28"') plotprefdict = {"with_" : "linespoints lt 1 lw 6" } elif "png" == terminaltype: gp('set termoption font "Times-Roman,18"') plotprefdict = {"with_" : "linespoints lw 2"} else: plotprefdict = {"with_" : "linespoints" } return gp, plotprefdict
def plot_ioprof(ioprof, outprefix, terminaltype = "png"): riops, wiops, rmbps, wmbps, riosize, wiosize = [[] for i in range(6)] t = len(ioprof) for vals in ioprof: riops.append(vals[2]) wiops.append(vals[3]) rmbps.append(vals[4]) wmbps.append(vals[5]) riosize.append((vals[4] * 1000.) / vals[2] if vals[2] != 0 else 0.) wiosize.append((vals[5] * 1000.) / vals[3] if vals[3] != 0 else 0.) gp = plotutil.gpinit(terminaltype) gp.xlabel("elapsed time [s]") gp('set grid') if slide: gp('set termoption font "Times-Roman,22"') plotprefdict = {"with_" : "lines lw 2"} else: plotprefdict = {"with_" : "lines"} # draw mbps graph output = "{0}mbps.{1}".format(outprefix, terminaltype) gp('set output "{0}"'.format(output)) gp.ylabel("MBps") gp.ylabel("I/O throughput [MB/s]") gp('set yrange [0:*]') gdrmbps = Gnuplot.Data(range(t), rmbps, title = "Read", **plotprefdict) gdwmbps = Gnuplot.Data(range(t), wmbps, title = "Write", **plotprefdict) gp.plot(gdrmbps, gdwmbps) sys.stdout.write("output {0}\n".format(output)) # draw iops graph output = "{0}iops.{1}".format(outprefix, terminaltype) gp('set output "{0}"'.format(output)) gp.ylabel("I/O throughput [IO/s]") gdriops = Gnuplot.Data(range(t), riops, title = "Read", **plotprefdict) gdwiops = Gnuplot.Data(range(t), wiops, title = "Write", **plotprefdict) gp.plot(gdriops, gdwiops) sys.stdout.write("output {0}\n".format(output)) # draw iosize graph output = "{0}iosize.{1}".format(outprefix, terminaltype) gp('set output "{0}"'.format(output)) gp.ylabel("I/O size [KB]") gdrios = Gnuplot.Data(range(t), riosize, title = "Read", **plotprefdict) gdwios = Gnuplot.Data(range(t), wiosize, title = "Write", **plotprefdict) gp.plot(gdrios, gdwios) sys.stdout.write("output {0}\n".format(output)) gp.close()
def init_gnuplot(terminaltype): gp = gpinit(terminaltype) gp('set logscale x 2') gp('set grid') if slide: if "eps" == terminaltype: gp('set termoption font "Times-Roman,28"') plotprefdict = {"with_" : "yerrorlines lt 1 lw 6" } elif "png" == terminaltype: gp('set termoption font "Times-Roman,18"') plotprefdict = {"with_" : "yerrorlines lw 2"} else: plotprefdict = {"with_" : "linespoints"}#"yerrorlines" } if terminaltype == "eps": gp('set size 1.4,1') return gp, plotprefdict
def plot_iocostprof(iocostprof, output, terminaltype): riocost, wiocost = [], [] t = len(iocostprof) for vals in iocostprof: riocost.append(vals[2] / interval) wiocost.append(vals[3] / interval) gp = plotutil.gpinit(terminaltype) gp('set output "{0}"'.format(output)) gp.xlabel("elapsed time [s]") gp.ylabel("I/O ratio [%]") gp('set grid front') gds = [] gds.append(Gnuplot.Data(range(t), riocost, title = "Read", with_ = "lines")) gds.append(Gnuplot.Data(range(t), wiocost, title = "Write", with_ = "lines")) gp.plot(*gds) sys.stdout.write("output {0}\n".format(output)) gp.close()
def draw_bucket(dbpath, terminaltype = "png"): conn = sqlite3.connect(dbpath) gp = gpinit(terminaltype) dirname = os.path.dirname(os.path.abspath(dbpath)) output = "{0}/bucketscan.{1}".format(dirname, terminaltype) gp('set output "{0}"'.format(output)) gp('set key inside left top') gp.xlabel("work\_mem [byte]") gp('set ylabel "# of bucket scan"') gp('set y2label "# of partition * # of bucket"') gp('set format x "%.0b%B"') gp('set logscale x 2') gp('set ytics nomirror') gp('set grid xtics noytics noy2tics') gp('set yrange[0:*]') y2max = conn.execute("select max(nbatch * nbucket) from bucketinfo").fetchone()[0] y2max = ceiltop(y2max) gp('set y2range[0:{0}]'.format(y2max)) gp('set y2tics {0}'.format(y2max / 10)) if slide: if "eps" == terminaltype: gp('set termoption font "Times-Roman,28"') plotprefdict = {"with_" : "points lt 1 lw 6" } elif "png" == terminaltype: gp('set termoption font "Times-Roman,18"') plotprefdict = {"with_" : "points lw 2"} else: plotprefdict = {"with_" : "points" } query = "select workmem, {0} from bucketinfo order by workmem" gds = [] datalist = query2data(conn, query.format("sum")) gds.append(Gnuplot.Data(datalist[0], datalist[1], [v / 4 for v in datalist[0]], title = "nbucketscan", axes = "x1y1", with_ = 'boxes lc rgb "blue" fs solid border lc rgb "black"')) gds.extend(query2gds(conn, query.format("nbatch * nbucket"), title = "npartition * nbucket", axes = "x1y2", **plotprefdict)) gp.plot(*gds) sys.stdout.write("output {0}\n".format(output)) gp.close() conn.close()
def plot_cachemiss_new(cacheprof, output, terminaltype = "png"): gp = plotutil.gpinit(terminaltype) gp('set output "{0}"'.format(output)) gp.xlabel('elapsed time [s]') gp('set ytics nomirror') gp('set ylabel "count" offset 4') gp('set y2label "rate [%]" offset -2') gp('set grid xtics noytics noy2tics') gp('set yrange [0:*]') gp('set y2range [0:100]') gp('set y2tic 10') gds = [] xaxis = [] y1axes = [{"name": "all cache ref", "values": []}, {"name": "L1D cache miss", "values": []}, {"name": "L2 cache miss", "values": []}, {"name": "L3 cache miss", "values": []}] y2axes = [{"name": "L1D cache miss rate", "values": []}, {"name": "L2 cache miss rate", "values": []}, {"name": "L3 cache miss rate", "values": []}] for v in cacheprof: xaxis.append(v[0]) for i, axis in enumerate(y1axes): axis["values"].append(v[i + 1]) for i, axis in enumerate(y2axes): axis["values"].append(float(v[i + 2]) / v[i + 1] * 100) plotprefdict = {"with_" : "lines"} for axis in y1axes: gds.append(Gnuplot.Data(xaxis, axis["values"], title = axis["name"], axes = "x1y1", **plotprefdict)) for axis in y2axes: gds.append(Gnuplot.Data(xaxis, axis["values"], title = axis["name"], axes = "x1y2", **plotprefdict)) gp.plot(*gds) sys.stdout.write("output {0}\n".format(output)) gp.close()
if __name__ == "__main__": if len(sys.args) < 2: sys.stdout.write("Usage : {0} dbpath [eps|png]\n".format(sys.argv[0])) sys.exit(1) dbpath = os.path.abspath(sys.argv[1]) terminaltype = sys.argv[2] if len(sys.argv) == 3 else "png" if terminaltype != "png" and terminaltype != "eps": sys.stdout.write("wrong terminal type\n") sys.exit(1) conn = sqlite3.connect(dbpath) cols = ["elapsed", "mbps", "iops", "latency"] tables = ["sequential_read", "random_read"] gp = pu.gpinit(terminaltype) #draw nlu-spec graph gp('set nologscale x') distinctsql = "select distinct nthread from {0} where iosize={1}" nthreadlistlist = [[r[0] for r in conn.execute(distinctsql.format(tbl, iosize))] for tbl in tables] gp.xlabel("nlu") for col in cols: gp('set title "{0} iosize = {1}"'.format(col, iosize)) gp.ylabel(col) if col == "mbps" or col == "iops": gp('set key left top') else: gp('set key right top') figpath = "{0}_xnlu.{1}".format(col, terminaltype) gp('set output "{0}"'.format(figpath))
if __name__ == "__main__": if len(sys.args) < 2: sys.stdout.write("Usage : {0} dbpath [eps|png]\n".format(sys.argv[0])) sys.exit(1) dbpath = os.path.abspath(sys.argv[1]) terminaltype = sys.argv[2] if len(sys.argv) == 3 else "png" if terminaltype != "png" and terminaltype != "eps": sys.stdout.write("wrong terminal type\n") sys.exit(1) conn = sqlite3.connect(dbpath) cols = ["elapsed", "mbps", "iops", "latency"] tables = ["sequential_read", "random_read"] gp = pu.gpinit(terminaltype) #draw nlu-spec graph gp('set nologscale x') distinctsql = "select distinct nthread from {0} where iosize={1}" nthreadlistlist = [[ r[0] for r in conn.execute(distinctsql.format(tbl, iosize)) ] for tbl in tables] gp.xlabel("nlu") for col in cols: gp('set title "{0} iosize = {1}"'.format(col, iosize)) gp.ylabel(col) if col == "mbps" or col == "iops": gp('set key left top') else: gp('set key right top') figpath = "{0}_xnlu.{1}".format(col, terminaltype)
else: sys.stdout.write("Usage : {0} dbpath [eps|png]\n".format(sys.argv[0])) sys.exit(1) if terminaltype != "png" and terminaltype != "eps": sys.stdout.write("wrong terminal type\n") sys.exit(1) conn = sqlite3.connect(dbpath) cols = ["elapsedtime", "mbps", "iops"] units = {"elapsed" : "(us)", "mbps" : "(MB/s)", "iops" : ""} tables = ["sequential_read", "random_read", "sequential_write", "random_write"] for i, col in enumerate(cols): gp = plotutil.gpinit(terminaltype) gp.xlabel("io size (B)") gp.ylabel("{0} {1}".format(col, units[col])) fpath = os.path.dirname(dbpath) + "/" + os.path.splitext(dbpath)[0].rsplit('_', 1)[1] figpath = "{0}_{1}.{2}".format(fpath, col, terminaltype) gp('set title "{0}"'.format(col)) gp('set output "{0}"'.format(figpath)) gp('set logscale x') if col == "mbps": gp('set key left top') query = "select iosize, {0} from {{table}}".format(col) gd = plotutil.query2data(conn, query, table = tables, with_ = "linespoints") gp.plot(*gd) gp.close()