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

fastlab-svn at coffeetalk-1.cc.gatech.edu fastlab-svn at coffeetalk-1.cc.gatech.edu
Wed Feb 12 12:54:10 EST 2014


Author: rcurtin
Date: Wed Feb 12 12:54:10 2014
New Revision: 16286

Log:
Add support for changing graph grid color.


Modified:
   mlpack/conf/jenkins-conf/benchmark/benchmark/make_reports.py
   mlpack/conf/jenkins-conf/benchmark/config.yaml
   mlpack/conf/jenkins-conf/benchmark/util/graph.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	Wed Feb 12 12:54:10 2014
@@ -33,16 +33,16 @@
 @param db - The database object.
 @return The filename of the line chart.
 '''
-def CreateTopLineChart(db, topChartColor, textColor):
+def CreateTopLineChart(db, topChartColor, textColor, gridColor):
   res = db.GetResultsSum("mlpack")
   if res:
     build, results = res
   else:
     return ""
 
-  GenerateSingleLineChart(results, "reports/img/mlpack_top_" + str(build) + 
+  GenerateSingleLineChart(results, "reports/img/mlpack_top_" + str(build) +
       ".png", backgroundColor=topChartColor, windowWidth=9, windowHeight=1.6,
-      textColor=textColor)
+      textColor=textColor, gridColor=gridColor)
   return "img/mlpack_top_" + str(build) + ".png"
 
 '''
@@ -67,7 +67,7 @@
       # Highlight the data with the best timing.
       if minData(timings) == time:
         time = str("{0:.4f}".format(time)) + "s" if isFloat(str(time)) else time
-        timingTable += '<td><p class="text-success"><strong>' + time 
+        timingTable += '<td><p class="text-success"><strong>' + time
         timingTable += "</strong></p></td>"
       else:
         time = str("{0:.4f}".format(time)) + "s" if isFloat(str(time)) else time
@@ -117,14 +117,14 @@
 @param results - This data structure contains the memory results.
 @return A string that contains the content for the memory section.
 '''
-def CreateMemoryContent(results, chartColor, textColor):
+def CreateMemoryContent(results, chartColor, textColor, gridColor):
   memoryContent = ""
   if results:
     for result in results:
       memoryValues = {}
       memoryValues["name"] = result[7]
       memoryValues["nameID"] = result[7] + str(hash(datetime.datetime.now()))
-      
+
       content = Profiler.MassifMemoryUsageReport(str(result[5]))
       try:
         content = content.decode()
@@ -133,7 +133,8 @@
       memoryValues["content"] = content
 
       filename = "img/massif_" + os.path.basename(result[5]).split('.')[0] + ".png"
-      CreateMassifChart(result[5], "reports/" + filename, chartColor, textColor)
+      CreateMassifChart(result[5], "reports/" + filename, chartColor, textColor,
+          gridColor)
       memoryValues["memoryChart"] = filename
 
       memoryContent += memoryPanelTemplate % memoryValues
@@ -161,7 +162,7 @@
 
     infoValues["content"] = content
     methodInfo = panelTemplate % infoValues
-  
+
   return methodInfo
 
 '''
@@ -170,7 +171,7 @@
 @param db - The database object.
 @return HTML code which contains the information for the container.
 '''
-def MethodReports(db, chartColor, textColor):
+def MethodReports(db, chartColor, textColor, gridColor):
   methodsPage = ""
   numDatasets = 0
 
@@ -179,11 +180,11 @@
   buildIds = []
   for libraryid in libraryIds:
     buildIds.append((db.GetLatestBuildFromLibary(libraryid[0]), libraryid[1]))
-  
+
   methodGroup = {}
   # Iterate throw all methods and create for each method a new container.
   for method in db.GetAllMethods():
-    
+
     methodResults = []
     methodLibararies = []
     resultBuildId = []
@@ -208,7 +209,7 @@
     # Create the container.
     reportValues = {}
     reportValues["methodName"] = methodName
-    
+
     resultPanel = ""
     methodInfo = ""
     memoryContent = ""
@@ -229,7 +230,7 @@
     for result in results:
       resultValues = {}
       groupPanel = {}
-      
+
       methodResults = result[0]
       methodLibararies = result[1]
       resultBuildId = result[2]
@@ -247,17 +248,17 @@
       else:
         continue
 
-      GenerateSingleLineChart(data=methodResultsSum, 
-          fileName="reports/" + lineChartName, backgroundColor=chartColor, 
-          textColor=textColor)
+      GenerateSingleLineChart(data=methodResultsSum,
+          fileName="reports/" + lineChartName, backgroundColor=chartColor,
+          textColor=textColor, gridColor=gridColor)
 
       # Generate a "unique" name for the bar chart.
       barChartName = "img/bar_" + chartHash + ".png"
 
       # Create the bar chart.
-      ChartInfo = GenerateBarChart(results=methodResults, 
-          libraries=methodLibararies, fileName="reports/" + barChartName, 
-          backgroundColor=chartColor, textColor=textColor)
+      ChartInfo = GenerateBarChart(results=methodResults,
+          libraries=methodLibararies, fileName="reports/" + barChartName,
+          backgroundColor=chartColor, textColor=textColor, gridColor=gridColor)
 
       numDatasets, totalTime, failure, timeouts, bestLibnum, timingData = ChartInfo
 
@@ -292,20 +293,21 @@
 
       # Create the memory content.
       if mlpackMemoryBuilId:
-        memoryResults = db.GetMemoryResults(mlpackMemoryBuilId, 
+        memoryResults = db.GetMemoryResults(mlpackMemoryBuilId,
             mlpackMemoryId[0][0], methodId)
 
-        groupPanel["content"] = CreateMemoryContent(memoryResults, chartColor, textColor)
+        groupPanel["content"] = CreateMemoryContent(memoryResults, chartColor,
+            textColor, gridColor)
         if groupPanel["content"]:
           groupPanel["nameID"] = chartHash + "_m"
           groupPanel["name"] = "Parameters: " + (parameters if parameters else "None")
-          
+
           memoryContent += resultsTemplate % groupPanel
 
       # Create the method info content.
       if not methodInfo:
         methodInfo = CreateMethodInfo(db.GetMethodInfo(methodId), methodName)
-      
+
     datasetTable = CreateDatasetTable(results)
 
     # Calculate the percent for the progress bar.
@@ -326,7 +328,7 @@
       reportValues["progressPositive"] = "0%"
       reportValues["progressPositiveStyle"] = "0%;"
       reportValues["progressNegativeStyle"] = "100%" + progressBarStyle
-    
+
     reportValues["numLibararies"] = libCount
     reportValues["numDatasets"] = datasetCount
     reportValues["totalTime"] =  "{0:.2f}".format(totalTimeCount)
@@ -361,7 +363,7 @@
     pattern = re.compile(r"""
         .*?index_(?P<id>.*?).html
         """, re.VERBOSE|re.MULTILINE|re.DOTALL)
-    
+
     match = pattern.match(f)
     if match:
       i = int(match.group("id"))
@@ -395,7 +397,7 @@
           content += '<li class="previous"><a href="index.html">&larr; Newer</a></li>\n'
         else:
           content += '<li class="previous"><a href="index_' + str(i - 1) + '.html">&larr; Newer</a></li>\n'
-        
+
         # If i equals maxId there is no next index file. In this case we can't
         # create a link to the next index file.
         if i == maxId:
@@ -410,7 +412,7 @@
         fid.write(content)
         fid.truncate()
 
-        # Delete unneeded files. We don't want to store all reports, for that 
+        # Delete unneeded files. We don't want to store all reports, for that
         # reason we delete the oldest report.
         if i < maxFiles:
           delFiles.extend(re.findall('src="img/(.*?)"', content))
@@ -432,14 +434,14 @@
 def NewPagination():
   maxId, files = GetMaxIndex()
 
-  # This is the new index file, for that reason there is never a link to a 
+  # This is the new index file, for that reason there is never a link to a
   # previous index file.
   pagination = '<li class="previous disabled"><a href="#">&larr; Newer</a></li>\n'
-  # If i is greater then maxId there is no next index file. In this case we 
+  # If i is greater then maxId there is no next index file. In this case we
   # can't create a link to the next index file.
   if maxId > 0:
     pagination += '<li class="next"><a href="index_1.html">Older &rarr;</a></li>\n'
-  else:    
+  else:
     pagination += '<li class="next disabled"><a href="#">Older &rarr;</a></li>'
 
   return pagination
@@ -447,7 +449,7 @@
 '''
 Rename the index_[number].html files.
 '''
-def ShiftReports(): 
+def ShiftReports():
   maxId, files = GetMaxIndex()
 
   # Iterate through all index_[number].html files and increase the number.
@@ -473,6 +475,7 @@
   topChartColor = "#F3F3F3"
   chartColor = "#FFFFFF"
   textColor = "#6e6e6e"
+  gridColor = "#6e6e6e"
 
   # Create the folder structure.
   CreateDirectoryStructure(["reports/img", "reports/etc"])
@@ -494,6 +497,8 @@
         chartColor = value
       elif key == "textColor":
         textColor = value
+      elif key == "gridColor":
+        gridColor = value
 
   db = Database(database)
   db.CreateTables()
@@ -503,9 +508,10 @@
 
   # Get the values for the new index.html file.
   reportValues = {}
-  reportValues["topLineChart"] = CreateTopLineChart(db, topChartColor, textColor)
+  reportValues["topLineChart"] = CreateTopLineChart(db, topChartColor,
+      textColor, gridColor)
   reportValues["pagination"] = NewPagination()
-  reportValues["methods"] = MethodReports(db, chartColor, textColor)
+  reportValues["methods"] = MethodReports(db, chartColor, textColor, gridColor)
 
   template = pageTemplate % reportValues
 
@@ -514,13 +520,13 @@
     fid.write(template)
 
 if __name__ == '__main__':
-  parser = argparse.ArgumentParser(description="""Perform the memory benchmark 
+  parser = argparse.ArgumentParser(description="""Perform the memory benchmark
       with the given config.""")
-  parser.add_argument('-c','--config', help='Configuration file name.', 
+  parser.add_argument('-c','--config', help='Configuration file name.',
       required=True)
 
   args = parser.parse_args()
 
   if args:
     Main(args.config)
-  
\ No newline at end of file
+

Modified: mlpack/conf/jenkins-conf/benchmark/config.yaml
==============================================================================
--- mlpack/conf/jenkins-conf/benchmark/config.yaml	(original)
+++ mlpack/conf/jenkins-conf/benchmark/config.yaml	Wed Feb 12 12:54:10 2014
@@ -5,9 +5,10 @@
     timeout: 9000
     database: 'reports/benchmark.db'
     keepReports: 20
-    topChartColor: '#F3F3F3'
-    chartColor: '#FFFFFF'
-    textColor: '#6E6E6E'
+    topChartColor: '#000000'
+    chartColor: '#000000'
+    textColor: '#aaaaaa'
+    gridColor: '#ffff00'
 ---
 #  MLPACK:
 #  A Scalable C++  Machine Learning Library

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	Wed Feb 12 12:54:10 2014
@@ -28,7 +28,7 @@
 
 
 # Use this colors to plot the graph.
-colors = ['#3366CC', '#DC3912', '#FF9900', '#FFFF32', '#109618', '#990099', 
+colors = ['#3366CC', '#DC3912', '#FF9900', '#FFFF32', '#109618', '#990099',
           '#DD4477', '#AAAA11', '#22AA99']
 
 '''
@@ -40,11 +40,11 @@
 @param bestlib - The name of the library which should be compared with the other
 libraries.
 @param backgroundColor - The color of the image background.
- at return The dataset count, total time, failure count, timeout count, 
+ at return The dataset count, total time, failure count, timeout count,
 best libray count, timing data.
 '''
-def GenerateBarChart(results, libraries, fileName, bestlib="mlpack", 
-    backgroundColor="#FFFFFF", textColor="#6e6e6e"):
+def GenerateBarChart(results, libraries, fileName, bestlib="mlpack",
+    backgroundColor="#FFFFFF", textColor="#6e6e6e", gridColor="#6e6e6e"):
   # Bar chart settings.
   lineWidth = 0.1
   barWidth = 0.15
@@ -57,13 +57,13 @@
   # Create figure and set the color.
   matplotlib.rc('axes', facecolor=backgroundColor)
   matplotlib.rcParams.update({'font.size': 8})
-  fig = plt.figure(figsize=(windowWidth, windowHeight), 
+  fig = plt.figure(figsize=(windowWidth, windowHeight),
       facecolor=backgroundColor, dpi=100)
   plt.rc('lines', linewidth=lineWidth)
   ax = plt.subplot(1,1,1)
 
   # Set the grid style.
-  ax.yaxis.grid(True, linestyle='-', linewidth=gridLineWidth)
+  ax.yaxis.grid(True, linestyle='-', linewidth=gridLineWidth, color=gridColor)
   ax.xaxis.grid(False)
   ax.spines['left'].set_visible(False)
   ax.spines['top'].set_visible(False)
@@ -80,7 +80,7 @@
   nextBar = 0
   legendPosition = 0
   legendBegin = 0
-  
+
   # use this variable to count the time.
   totalTime = 0
   # Use this variable to count the timeouts.
@@ -92,9 +92,9 @@
   timingData = {}
 
   # Use this variable to get use the data for the right library.
-  l = 0 
+  l = 0
   # Iterate through the data and plot the bar chart.
-  for result in results:    
+  for result in results:
     for i, data in enumerate(result):
       # The time value.
       time = data[3]
@@ -137,10 +137,10 @@
       color = colors[l % len(colors)]
 
       if isFloat(value):
-        plt.bar(nextBar, value, barWidth, alpha=opacity, color=color, 
+        plt.bar(nextBar, value, barWidth, alpha=opacity, color=color,
             fill=fill,lw=0.2)
       else:
-        plt.bar(nextBar, maxValue, barWidth, alpha=opacity, color="gray", 
+        plt.bar(nextBar, maxValue, barWidth, alpha=opacity, color="gray",
             fill=fill, lw=0.2)
 
       time = value if isFloat(value) else 10
@@ -165,8 +165,8 @@
   ax.tick_params(axis='both', which='minor', labelsize=6, labelcolor=textColor)
 
   # Create the legend above the bar chart.
-  lgd = ax.legend(handler, libraries + ["failure/ timeout"], loc='upper center', 
-    bbox_to_anchor=(0.5, 1.3 + (0.2 * len(libraries) / 6)), fancybox=True, 
+  lgd = ax.legend(handler, libraries + ["failure/ timeout"], loc='upper center',
+    bbox_to_anchor=(0.5, 1.3 + (0.2 * len(libraries) / 6)), fancybox=True,
     shadow=False, ncol=6, fontsize=8)
   lgd.get_frame().set_linewidth(0)
   for label in lgd.get_texts():
@@ -177,7 +177,7 @@
 
   # Save the bar chart.
   fig.tight_layout()
-  fig.savefig(fileName, bbox_extra_artists=(lgd,), bbox_inches='tight', 
+  fig.savefig(fileName, bbox_extra_artists=(lgd,), bbox_inches='tight',
     facecolor=fig.get_facecolor(), edgecolor='none', format='png', dpi=100)
   plt.close()
 
@@ -192,7 +192,7 @@
       results = [v if isFloat(v) else float('Inf') for v in results]
       if bestLibIndex == results.index(min(results)):
         bestLibCount += 1
-  
+
   return (len(timingData), totalTime, failure, timeouts, bestLibCount, timingData)
 
 '''
@@ -204,10 +204,10 @@
 @param windowWidth - The width of the chart.
 @prama windowHeight - The height of the chart.
 '''
-def GenerateSingleLineChart(data, fileName, backgroundColor="#FFFFFF", 
-    windowWidth=8.1, windowHeight=1.3, textColor="#6e6e6e"):
-  
-  # Generate a list of scalar values. Use the privious or next elemnt to fill 
+def GenerateSingleLineChart(data, fileName, backgroundColor="#FFFFFF",
+    windowWidth=8.1, windowHeight=1.3, textColor="#6e6e6e", gridColor="#6e6e6e"):
+
+  # Generate a list of scalar values. Use the privious or next elemnt to fill
   # the gap.
   def NormalizeData(data):
     i = 0
@@ -229,13 +229,13 @@
   # Create figure and set the color.
   matplotlib.rc('axes', facecolor=backgroundColor)
   matplotlib.rcParams.update({'font.size': 8})
-  fig = plt.figure(figsize=(windowWidth, windowHeight), 
+  fig = plt.figure(figsize=(windowWidth, windowHeight),
       facecolor=backgroundColor, dpi=100)
   plt.rc('lines', linewidth=lineWidth)
   ax = plt.subplot(1,1,1)
 
   # Set the grid style.
-  ax.yaxis.grid(True, linestyle='-', linewidth=gridLineWidth)
+  ax.yaxis.grid(True, linestyle='-', linewidth=gridLineWidth, color=gridColor)
   ax.xaxis.grid(False)
   ax.spines['left'].set_visible(False)
   ax.spines['top'].set_visible(False)
@@ -250,11 +250,11 @@
 
   data = NormalizeData(data)
 
-  # If we only have a single value we don't want to start from zero so we 
+  # If we only have a single value we don't want to start from zero so we
   # double the data.
   if len(data) == 1:
     data += data
-      
+
   # Create the data for the x-axis.
   X = list(range(len(data)))
 
@@ -271,7 +271,7 @@
 
   # Save the line chart.
   fig.tight_layout()
-  fig.savefig(fileName, bbox_inches='tight', facecolor=fig.get_facecolor(), 
+  fig.savefig(fileName, bbox_inches='tight', facecolor=fig.get_facecolor(),
       edgecolor='none', dpi=100)
   plt.close()
 
@@ -282,7 +282,8 @@
 @param fileName - The filename of the memory chart.
 @param backgroundColor - The color of the image background.
 '''
-def CreateMassifChart(massiflogFile, fileName, backgroundColor="#FFFFFF", textColor="6e6e6e"):
+def CreateMassifChart(massiflogFile, fileName, backgroundColor="#FFFFFF",
+    textColor="6e6e6e", gridColor="#6e6e6e"):
   lineWidth = 1.5
   opacity = 0.9
   windowWidth = 8.1
@@ -292,13 +293,13 @@
   # Create figure and set the color.
   matplotlib.rc('axes', facecolor=backgroundColor)
   matplotlib.rcParams.update({'font.size': 8})
-  fig = plt.figure(figsize=(windowWidth, windowHeight), 
+  fig = plt.figure(figsize=(windowWidth, windowHeight),
       facecolor=backgroundColor, dpi=100)
   plt.rc('lines', linewidth=lineWidth)
   ax = plt.subplot(1,1,1)
 
   # Set the grid style.
-  ax.yaxis.grid(True, linestyle='-', linewidth=gridLineWidth)
+  ax.yaxis.grid(True, linestyle='-', linewidth=gridLineWidth, color=gridColor)
   ax.xaxis.grid(False)
   ax.spines['left'].set_visible(False)
   ax.spines['top'].set_visible(False)
@@ -341,15 +342,15 @@
   plt.xlabel("snapshot", color=textColor)
 
   # 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', 
+  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(textColor)
-         
+
   # Save the memory chart.
   fig.tight_layout()
-  fig.savefig(fileName, bbox_extra_artists=(lgd,), bbox_inches='tight', 
+  fig.savefig(fileName, bbox_extra_artists=(lgd,), bbox_inches='tight',
     facecolor=fig.get_facecolor(), edgecolor='none', format='png', dpi=100)
   plt.close()



More information about the mlpack-svn mailing list