[mlpack-svn] r15622 - in mlpack/conf/jenkins-conf/benchmark: benchmark util

fastlab-svn at coffeetalk-1.cc.gatech.edu fastlab-svn at coffeetalk-1.cc.gatech.edu
Thu Aug 15 11:56:42 EDT 2013


Author: marcus
Date: Thu Aug 15 11:56:42 2013
New Revision: 15622

Log:
Add memory graph to the results page.

Modified:
   mlpack/conf/jenkins-conf/benchmark/benchmark/make_reports.py
   mlpack/conf/jenkins-conf/benchmark/util/graph.py
   mlpack/conf/jenkins-conf/benchmark/util/template.py

Modified: mlpack/conf/jenkins-conf/benchmark/benchmark/make_reports.py
==============================================================================
--- mlpack/conf/jenkins-conf/benchmark/benchmark/make_reports.py	(original)
+++ mlpack/conf/jenkins-conf/benchmark/benchmark/make_reports.py	Thu Aug 15 11:56:42 2013
@@ -108,8 +108,14 @@
     for result in results:
       memoryValues = {}
       memoryValues["name"] = result[7]
+      memoryValues["nameID"] = result[7] + str(hash(datetime.datetime.now()))
       memoryValues["content"] = Profiler.MassifMemoryUsageReport(str(result[5])).lstrip(" ")
-      memoryContent += panelTemplate % memoryValues
+
+      filename = "img/massif_" + os.path.basename(result[5]).split('.')[0] + ".png"    
+      CreateMassifChart(result[5], "reports/" + filename)
+      memoryValues["memoryChart"] = filename
+
+      memoryContent += memoryPanelTemplate % memoryValues
 
   return memoryContent
 
@@ -125,6 +131,7 @@
   if results:
     infoValues = {}
     infoValues["name"] = methodName
+    infoValues["nameID"] = methodName + str(hash(datetime.datetime.now()))
     infoValues["content"] =results[0][2].lstrip(" ")
     methodInfo = panelTemplate % infoValues
   
@@ -299,6 +306,8 @@
 @param configfile - Create the reports with the given configuration file.
 '''
 def Main(configfile):
+  # CreateMassifChart("reports/etc/-2043538483674198236.mout")
+  # exit()
   # Reports settings.
   database = "reports/benchmark.db"
 

Modified: mlpack/conf/jenkins-conf/benchmark/util/graph.py
==============================================================================
--- mlpack/conf/jenkins-conf/benchmark/util/graph.py	(original)
+++ mlpack/conf/jenkins-conf/benchmark/util/graph.py	Thu Aug 15 11:56:42 2013
@@ -23,6 +23,7 @@
 
 import matplotlib.pyplot as plt
 import matplotlib.ticker as mticker
+import re
 
 
 # Use this colors to plot the graph.
@@ -36,7 +37,8 @@
 @param libraries - A list that contains the names of the libraries.
 @param fileName - The filename of the line chart.
 @param bestlib - The name of the library which should be compared with the other
-                 libraries.
+libraries.
+ at param backgroundColor - The color of the image background.
 '''
 def GenerateBarChart(results, libraries, fileName, bestlib="mlpack", 
     backgroundColor="#FFFFFF"):
@@ -163,7 +165,7 @@
   ax.tick_params(axis='both', which='major', labelsize=8, labelcolor="#6e6e6e")
   ax.tick_params(axis='both', which='minor', labelsize=6, labelcolor="#6e6e6e")
 
-  # Create the legend under the bar chart.
+  # Create the legend above the bar chart.
   lgd = ax.legend(chartHandler, legendNames, loc='upper center', 
     bbox_to_anchor=(0.5, 1.3), fancybox=True, shadow=False, ncol=8, fontsize=8)
   lgd.get_frame().set_linewidth(0)
@@ -188,9 +190,10 @@
 
 @param data - List which contains the values for the line chart.
 @param fileName - The filename of the line chart.
+ at param backgroundColor - The color of the image background.
 '''
 def GenerateSingleLineChart(data, fileName, backgroundColor="#FFFFFF"):
-  # Bar chart settings.
+  # Line chart settings.
   lineWidth = 1.5
   opacity = 0.9
   windowWidth = 10.6
@@ -224,7 +227,7 @@
     data += data
     
   # Create the data for the x-axis.
-  X = np.arange(len(data))  
+  X = np.arange(len(data))
 
   # Plot the line chart.
   plt.plot(X, data, color=colors[0], alpha=opacity)
@@ -237,3 +240,75 @@
   fig.savefig(fileName, bbox_inches='tight', facecolor=fig.get_facecolor(), 
       edgecolor='none')
   plt.close()
+
+'''
+Generate a memory chart with the specified informations.
+
+ at param massiflogFile - The massif logfile.
+ at param fileName - The filename of the memory chart.
+ at param backgroundColor - The color of the image background.
+'''
+def CreateMassifChart(massiflogFile, fileName, backgroundColor="#FFFFFF"):
+  lineWidth = 1.5
+  opacity = 0.9
+  windowWidth = 10.2
+  windowHeight = 1.5
+  gridLineWidth = 0.2
+
+  # Create figure and set the color.
+  matplotlib.rc('axes', facecolor=backgroundColor)
+  matplotlib.rcParams.update({'font.size': 8})
+  fig = plt.figure(figsize=(windowWidth, windowHeight), 
+      facecolor=backgroundColor, dpi=80)
+  plt.rc('lines', linewidth=lineWidth)
+  ax = plt.subplot(1,1,1)
+
+  # Set the grid style.
+  ax.yaxis.grid(True, linestyle='-', linewidth=gridLineWidth)
+  ax.xaxis.grid(False)
+  ax.spines['left'].set_visible(False)
+  ax.spines['top'].set_visible(False)
+  ax.spines['right'].set_visible(False)
+  ax.get_xaxis().tick_bottom()
+  ax.get_yaxis().tick_left()
+  ax.spines['bottom'].set_linewidth(gridLineWidth)
+
+  # Read the massif logfile.
+  with open(massiflogFile, "r") as fid:
+    content = fid.read()
+
+  # Parse the massif logfile.
+  memHeapB = [int(i) for i in re.findall(r"mem_heap_B=(\d*)", content)]
+  memHeapExtraB = [int(i) for i in  re.findall(r"mem_heap_extra_B=(\d*)", content)]
+  memStackB = [int(i) for i in  re.findall(r"mem_stacks_B=(\d*)", content)]
+
+  # Plot the memory information.
+  X = np.arange(len(memHeapExtraB))
+  # plt.fill_between(X, memHeapB, 0, color='g', alpha=0.6)
+  # plt.fill_between(X, memHeapB, memHeapExtraB, color='y', alpha=0.6)
+  # plt.fill_between(X, memHeapB, memStackB, color='r', alpha=0.6)
+  plt.fill_between(X, memHeapExtraB, 0, color="#109618", alpha=0.6)
+  plt.fill_between(X, memHeapExtraB, memHeapB, color="#DC3912", alpha=0.6)
+  plt.fill_between(X, memHeapExtraB, memStackB, color="#3366CC", alpha=0.6)
+
+  # Set the color and the font of the x-axis and y-axis labels.
+  ax.tick_params(axis='both', which='major', labelsize=8, labelcolor="#6e6e6e")
+  ax.tick_params(axis='both', which='minor', labelsize=6, labelcolor="#6e6e6e")
+
+  # Create a proxy artist, because fill_between hasn't a chart handler.
+  p1 = plt.Rectangle((0, 0), 1, 1, fc="#109618", alpha=0.6)
+  p2 = plt.Rectangle((0, 0), 1, 1, fc="#DC3912", alpha=0.6)
+  p3 = plt.Rectangle((0, 0), 1, 1, fc="#3366CC", alpha=0.6)
+
+  # Create the legend above the memory chart.
+  lgd = ax.legend((p1, p2, p3), 
+    ("mem heap B", "mem heap extra B", "mem stacks B"), loc='upper center', 
+    bbox_to_anchor=(0.5, 1.3), fancybox=True, shadow=False, ncol=8, fontsize=8)
+  lgd.get_frame().set_linewidth(0)
+  for label in lgd.get_texts():
+    label.set_color("#6e6e6e")
+       
+  # Save the memory chart.
+  fig.savefig(fileName, bbox_extra_artists=(lgd,), bbox_inches='tight', 
+    facecolor=fig.get_facecolor(), edgecolor='none', format='png')
+  plt.close()  

Modified: mlpack/conf/jenkins-conf/benchmark/util/template.py
==============================================================================
--- mlpack/conf/jenkins-conf/benchmark/util/template.py	(original)
+++ mlpack/conf/jenkins-conf/benchmark/util/template.py	Thu Aug 15 11:56:42 2013
@@ -30,12 +30,10 @@
           <div class="container__topContent">
             <div>
               <img class="center--image" src="%(topLineChart)s" alt="">
-            </div>          
+            </div>
           </div>
         </div>
-
         %(methods)s
-
         </div>
       </div>
     </div>
@@ -64,7 +62,7 @@
     <script src="js/slider.js"></script>
     <!--[if lte IE 7]>
       <script src="framework/font/lte-ie7.js"></script>
-    <![endif]-->      
+    <![endif]-->
     </body>
 </html>
 """
@@ -85,17 +83,13 @@
               <a href="#collapseThree" class="btn memory btn-grey icon-paragraph-right-2 js-button"></a>
             </div>
           </div>
-
           <div id="collapseOne" class="container__bottomContent graph collapse">
-
             <div>
               <img class="panel" src="%(lineChart)s" alt="">
             </div>
-
             <div>
               <img class="panel" src="%(barChart)s" alt="">
             </div>
-
             <div>
               <div class="panel">
                 <table class="table table-striped">
@@ -109,10 +103,9 @@
                     %(timingTable)s
                   </tbody>
                 </table>
-              </div>            
+              </div>
             </div>
           </div>
-
           <div id="collapseTwo" class="container__bottomContent infos collapse">
             <div>
               <div class="panel">
@@ -123,7 +116,7 @@
                       <th>Size</th>   
                       <th>Number of Instances</th>
                       <th>Number of Attributes</th>
-                      <th>Attribute Types</th>                                     
+                      <th>Attribute Types</th>
                     </tr>
                   </thead>
                   <tbody>
@@ -134,24 +127,16 @@
               </div>
             </div>
           </div>
-
           <div id="collapseTwo" class="container__bottomContent memories collapse">
             <div>
-              <div class="panel">
-                <div class="panel-heading">Massif Log</div>
-                  %(memoryContent)s
-              </div>
-
-            </div>
-          </div>
-
+            </div>%(memoryContent)s</div>
           <div class="container__bottomContent">&#160;</div>
            <div class="row">
             <div class="col-lg-2">Libraries: %(numLibararies)s</div>
             <div class="col-lg-2">Datasets: %(numDatasets)s</div>
             <div class="col-lg-3">Total time: %(totalTime)s seconds</div>
             <div class="col-lg-2">Script failure: %(failure)s</div>
-            <div class="col-lg-2">Timeouts failure: %(timeouts)s</div>          
+            <div class="col-lg-2">Timeouts failure: %(timeouts)s</div>
           </div>
           <div class="row">
             <div class="col-lg-10">Parameters: %(parameters)s</div>
@@ -160,10 +145,24 @@
 
 """
 
+memoryPanelTemplate = """
+<div class="panel">
+  <div><img class="center--image" src="%(memoryChart)s" alt=""></div>
+  <div class="accordion-group">
+  <div class="accordion-heading"><a class="accordion-toggle" data-toggle="collapse" data-parent="#accordion2" href="#%(nameID)s">%(name)s</a></div>
+    <div id="%(nameID)s" class="accordion-body collapse">
+      <div class="accordion-inner">
+      <pre>%(content)s</pre>
+      </div>
+    </div>
+  </div>
+</div>
+"""
+
 panelTemplate = """
 <div class="accordion-group">
-<div class="accordion-heading"><a class="accordion-toggle" data-toggle="collapse" data-parent="#accordion2" href="#%(name)s">%(name)s</a></div>
-  <div id="%(name)s" class="accordion-body collapse">
+<div class="accordion-heading"><a class="accordion-toggle" data-toggle="collapse" data-parent="#accordion2" href="#%(nameID)s">%(name)s</a></div>
+  <div id="%(nameID)s" class="accordion-body collapse">
     <div class="accordion-inner">
     <pre>%(content)s</pre>
     </div>



More information about the mlpack-svn mailing list