diff --git a/ilp-measurement.ipynb b/ilp-measurement.ipynb index 5c2adb11c6b4710fa5990559bb76dfcb0207d7bc..4354d55ba05e41ec4648a9f8c844757d9126303a 100644 --- a/ilp-measurement.ipynb +++ b/ilp-measurement.ipynb @@ -11,6 +11,7 @@ "import numpy as np\n", "import matplotlib.pyplot as plt\n", "import matplotlib.axes, matplotlib.ticker\n", + "import matplotlib.patches as mpatches\n", "%matplotlib inline\n", "plt.ioff()" ] @@ -653,7 +654,17 @@ }, "outputs": [], "source": [ - "def setBoxColors(bp, c, c2 = None, apply_to = None):\n", + "def setBoxColors(bp, c, c2 = None, apply_to = None, newstyle = False, linewidth=2):\n", + " if newstyle:\n", + " if c2 is None:\n", + " c2 = 'white' if c in ('black', 'blue') else 'black'\n", + " for box in bp['boxes']:\n", + " box.set(facecolor = c, linewidth=linewidth)\n", + " for median in bp['medians']:\n", + " median.set(color=c2, linewidth=linewidth)\n", + " for whisker in bp['whiskers']:\n", + " whisker.set(ls = 'dotted', color='black')\n", + " return\n", " if c2 is None:\n", " c2 = c\n", " set_c = functools.partial(plt.setp, color=c)\n", @@ -696,21 +707,12 @@ "text": [ "\n", "java:\n", - " update,normal,flush,noncached\n", - " sw,normal,flush,noncached\n", - " res,normal,flush,noncached\n", " mixed,normal,flush,noncached\n", "\n", "racket:\n", - " update,normal,flush,noncached\n", - " sw,normal,flush,noncached\n", - " res,normal,flush,noncached\n", " mixed,normal,flush,noncached\n", "\n", "larceny:\n", - " update,normal,flush,noncached\n", - " sw,normal,flush,noncached\n", - " res,normal,flush,noncached\n", " mixed,normal,flush,noncached\n" ] } @@ -718,18 +720,18 @@ "source": [ "for (data, name) in ((java_dats, 'java'), (racket_dats, 'racket'), (larceny_dats, 'larceny')):\n", " sys.stdout.write('\\n{}:'.format(name))\n", - "# change, strategy = 'mixed', 'normal'\n", - " for change in kinds['changes']:\n", + " change, strategy = 'mixed', 'normal'\n", + "# for change in kinds['changes']:\n", + " if True:\n", " if change == 'complex':\n", " continue\n", - "# if True:\n", " sys.stdout.write('\\n {}'.format(change))\n", "# if True:\n", " for strategy in kinds['strategies']:\n", " sys.stdout.write(','+strategy)\n", " cdat = data[change][strategy]\n", - " bp = plt.boxplot(cdat.transpose())\n", - " setBoxColors(bp, strategy_colors[strategy])\n", + " bp = plt.boxplot(cdat.transpose(), patch_artist=True)\n", + " setBoxColors(bp, strategy_colors[strategy], newstyle=True, linewidth=1)\n", " axes = plt.gca()\n", " axes.set_ylim([0,50])\n", "# plt.title('{0} {1} {2}'.format(name.title(), change_to_title(change), strategy_to_titel(strategy)))\n", @@ -738,6 +740,8 @@ " if change == 'mixed':\n", " for i, label in enumerate(axes.get_xticklabels()):\n", " label.set_visible(i==0 or (i+1) % 10 == 0)\n", + "# plt.gca().tick_params(axis='x', direction='out', top = 'off', bottom = 'on')\n", + " plt.gca().tick_params(axis='x', top = 'off', bottom = 'off')\n", " plt.savefig('pngs/gen_bp_{0}_{1}_{2}.png'.format(name,change,strategy))\n", " plt.savefig('doc/gen_bp_{0}_{1}_{2}.pdf'.format(name,change,strategy))\n", " plt.close()\n", @@ -757,40 +761,54 @@ "metadata": { "collapsed": false }, - "outputs": [], + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "\n", + " update\n", + " res\n", + " sw" + ] + } + ], "source": [ "width = 0.6\n", "name = 'racket'\n", - "for change in ['update', 'res', 'sw']:\n", - "#change = 'sw'\n", + "for change in ['update', 'res', 'sw']:#, 'mixed']:\n", + "#change = 'mixed'\n", "#if True:\n", - " #x*4*width + n*width\n", + " sys.stdout.write('\\n {}'.format(change))\n", " invisibles = []\n", " for i, strategy in enumerate(['noncached', 'flush', 'normal']):\n", - "# i, strategy, c = 1, 'flush', 'green'\n", + "# i, strategy = 1, 'flush'\n", "# if True:\n", " y = racket_dats[change][strategy]\n", " c = strategy_colors[strategy]\n", - " bp = plt.boxplot(y.transpose(), positions = np.arange(y.shape[0])*4+i)\n", - " setBoxColors(bp, c)\n", - " line, = plt.plot([1,1],c[0]+'-')\n", - " invisibles.append((line,strategy))\n", + " bp = plt.boxplot(y.transpose(), patch_artist=True, positions = np.arange(y.shape[0])*4+i)\n", + " setBoxColors(bp, c, newstyle=True)\n", + "# line, = plt.plot([1,1],c[0]+'-')\n", + " invisibles.append(mpatches.Patch(color=c, label=strategy_to_titel(strategy)))\n", " axes = plt.gca()\n", - " axes.set_xlim([-1,27])\n", + " y_len = y.shape[0]\n", " axes.set_ylim([0,50])\n", " plt.ylabel('seconds')\n", " plt.xlabel('step')\n", - " axes.set_xticklabels(range(1,8))\n", - " axes.set_xticks(range(1,29,4))\n", + " if change == 'mixed':\n", + " axes.set_xlim([-1,y_len*4+1])\n", + " axes.set_xticklabels(range(0,111,10))\n", + " axes.set_xticks(range(1,y_len*4+41,40))\n", + " else:\n", + " axes.set_xlim([-1,y_len*4-1])\n", + " axes.set_xticklabels(range(1,y_len+1))\n", + " axes.set_xticks(range(1,y_len*4,4))\n", "\n", - " # draw temporary red and blue lines and use them to create a legend\n", - " plt.legend([l for (l,n) in invisibles],[n for (l,n) in invisibles])\n", - " [l.set_visible(False) for (l,n) in invisibles]\n", + " plt.legend(handles=invisibles, loc='best')\n", "\n", " plt.savefig('pngs/gen_bp_{0}_{1}.png'.format(name,change))\n", " plt.savefig('doc/gen_bp_{0}_{1}.pdf'.format(name,change))\n", - " plt.close()\n", - "# plt.show()" + " plt.close()" ] }, { @@ -920,8 +938,8 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "1) {X}basline: `total.X.computed / total.X.called`\n", - "- the baseline of the method X" + "1) {X}cache-miss-rate: `total.X.computed / total.X.called`\n", + "- the rate for cache-misses (1 - cache-hits) of the method X" ] }, { @@ -942,10 +960,10 @@ "\n", "plt.legend(loc = 'best')\n", "plt.ylabel('% computed')\n", - "plt.suptitle('Attribute Baselines', fontsize = 16)\n", - "plt.savefig('doc/att_bl.pdf')\n", - "!pdfcrop doc/att_bl.pdf doc/att_bl_cropped.pdf > /dev/null\n", - "plt.savefig('pngs/att_bl.png')\n", + "#plt.suptitle('Cache Miss-Rate', fontsize = 16)\n", + "plt.savefig('doc/att_miss.pdf')\n", + "!pdfcrop doc/att_miss.pdf doc/att_miss_cropped.pdf > /dev/null\n", + "plt.savefig('pngs/att_miss.png')\n", "plt.close()" ] }, @@ -976,7 +994,7 @@ "\n", "plt.legend(loc = 'best')\n", "plt.ylabel('%')\n", - "plt.suptitle('Attribute Ratios', fontsize = 16)\n", + "#plt.suptitle('Attribute Ratios', fontsize = 16)\n", "plt.savefig('doc/att_r.pdf')\n", "!pdfcrop doc/att_r.pdf doc/att_r_cropped.pdf > /dev/null\n", "plt.savefig('pngs/att_r.png')\n", @@ -1122,7 +1140,7 @@ "name": "stdout", "output_type": "stream", "text": [ - "Drawing baselines\n", + "Drawing cache-miss rate\n", "Drawing ratios\n", "Drawing speed-ups\n" ] @@ -1131,9 +1149,9 @@ "source": [ "def baseline(x):\n", " return '{}Baseline'.format('flushed' if x == 'flush' else x)\n", - "print 'Drawing baselines'\n", + "print 'Drawing cache-miss rate'\n", "draw_att(kinds['strategies'], baseline, functools.partial(strategy_to_titel, length = lshort),\n", - " 'Attribute Baselines', 'att_box_bl')\n", + " 'Attribute Cache-Miss Rate', 'att_box_miss')\n", "x = ['NormalToFlushed', 'NormalToNoncached', 'FlushedToNoncached']\n", "print 'Drawing ratios'\n", "draw_att(x, lambda x: 'ratio{}'.format(x), strategy2_to_titel, 'Attribute Ratios', 'att_box_r', rotation_xaxis = 30)\n", diff --git a/ilp_measurement.py b/ilp_measurement.py index 8b7b3b5e8425600e210626c307f0aa565b14e4d5..a56f52895bc1128fb112b2d1c172f27f743d8c23 100644 --- a/ilp_measurement.py +++ b/ilp_measurement.py @@ -29,15 +29,16 @@ all_att_header = ['dir', 'attname', 'normalex', 'normalcalled', 'flushedex', 'f all_results = 'all.csv' class timed(object): - def __enter__(self, msg = ' done in {0:.3f}s'): - print 'Starting measurement at {:%d, %b %Y at %H:%M:%S.%f}'.format(datetime.today()) + def __enter__(self, what = 'measurement', msg = ' done in {0:.3f}s'): + print 'Starting {} at {:%d, %b %Y at %H:%M:%S.%f}'.format(what, datetime.today()) self.start = timeit.default_timer() self.msg = msg + self.what = what return self def __exit__(self, ex_type, value, traceback): self.stop = timeit.default_timer() - self.start print self.msg.format(self.stop) - print 'Finished measurement at {:%d, %b %Y at %H:%M:%S.%f}'.format(datetime.today()) + print 'Finished {} at {:%d, %b %Y at %H:%M:%S.%f}'.format(what, datetime.today()) @task(name = 'current-ids') def current_ids(): @@ -111,7 +112,7 @@ def do_sol(solver, number, pathname, skip_conflate): os.chdir(old_cd) continue files.sort() - with timed(): + with timed('solving'): total_start = timeit.default_timer() add_header = not os.path.exists(sol_results) with open(sol_results, 'a') as fd: