[mlpack-svn] r15969 - 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 Oct 9 15:45:24 EDT 2013


Author: marcus
Date: Wed Oct  9 15:45:24 2013
New Revision: 15969

Log:
Add option to set the chart text color.

Modified:
   mlpack/conf/jenkins-conf/benchmark/benchmark/make_reports.py
   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 Oct  9 15:45:24 2013
@@ -33,7 +33,7 @@
 @param db - The database object.
 @return The filename of the line chart.
 '''
-def CreateTopLineChart(db, topChartColor):
+def CreateTopLineChart(db, topChartColor, textColor):
   res = db.GetResultsSum("mlpack")
   if res:
     build, results = res
@@ -41,7 +41,8 @@
     return ""
 
   GenerateSingleLineChart(results, "reports/img/mlpack_top_" + str(build) + 
-      ".png", backgroundColor=topChartColor, windowWidth=9, windowHeight=1.6)
+      ".png", backgroundColor=topChartColor, windowWidth=9, windowHeight=1.6,
+      textColor=textColor)
   return "img/mlpack_top_" + str(build) + ".png"
 
 '''
@@ -116,7 +117,7 @@
 @param results - This data structure contains the memory results.
 @return A string that contains the content for the memory section.
 '''
-def CreateMemoryContent(results, chartColor):
+def CreateMemoryContent(results, chartColor, textColor):
   memoryContent = ""
   if results:
     for result in results:
@@ -132,7 +133,7 @@
       memoryValues["content"] = content
 
       filename = "img/massif_" + os.path.basename(result[5]).split('.')[0] + ".png"
-      CreateMassifChart(result[5], "reports/" + filename, chartColor)
+      CreateMassifChart(result[5], "reports/" + filename, chartColor, textColor)
       memoryValues["memoryChart"] = filename
 
       memoryContent += memoryPanelTemplate % memoryValues
@@ -169,7 +170,7 @@
 @param db - The database object.
 @return HTML code which contains the information for the container.
 '''
-def MethodReports(db, chartColor):
+def MethodReports(db, chartColor, textColor):
   methodsPage = ""
   numDatasets = 0
 
@@ -246,8 +247,9 @@
       else:
         continue
 
-      GenerateSingleLineChart(methodResultsSum, "reports/" + lineChartName, 
-          chartColor)
+      GenerateSingleLineChart(data=methodResultsSum, 
+          fileName="reports/" + lineChartName, backgroundColor=chartColor, 
+          textColor=textColor)
 
       # Generate a "unique" name for the bar chart.
       barChartName = "img/bar_" + chartHash + ".png"
@@ -255,7 +257,7 @@
       # Create the bar chart.
       ChartInfo = GenerateBarChart(results=methodResults, 
           libraries=methodLibararies, fileName="reports/" + barChartName, 
-          backgroundColor=chartColor)
+          backgroundColor=chartColor, textColor=textColor)
 
       numDatasets, totalTime, failure, timeouts, bestLibnum, timingData = ChartInfo
 
@@ -293,7 +295,7 @@
         memoryResults = db.GetMemoryResults(mlpackMemoryBuilId, 
             mlpackMemoryId[0][0], methodId)
 
-        groupPanel["content"] = CreateMemoryContent(memoryResults, chartColor)
+        groupPanel["content"] = CreateMemoryContent(memoryResults, chartColor, textColor)
         if groupPanel["content"]:
           groupPanel["nameID"] = chartHash + "_m"
           groupPanel["name"] = "Parameters: " + (parameters if parameters else "None")
@@ -470,6 +472,7 @@
   keepReports = 3
   topChartColor = "#F3F3F3"
   chartColor = "#FFFFFF"
+  textColor = "#6e6e6e"
 
   # Create the folder structure.
   CreateDirectoryStructure(["reports/img", "reports/etc"])
@@ -489,6 +492,8 @@
         topChartColor = value
       elif key == "chartColor":
         chartColor = value
+      elif key == "textColor":
+        textColor = value
 
   db = Database(database)
   db.CreateTables()
@@ -498,9 +503,9 @@
 
   # Get the values for the new index.html file.
   reportValues = {}
-  reportValues["topLineChart"] = CreateTopLineChart(db, topChartColor)
+  reportValues["topLineChart"] = CreateTopLineChart(db, topChartColor, textColor)
   reportValues["pagination"] = NewPagination()
-  reportValues["methods"] = MethodReports(db, chartColor)
+  reportValues["methods"] = MethodReports(db, chartColor, textColor)
 
   template = pageTemplate % reportValues
 

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 Oct  9 15:45:24 2013
@@ -44,7 +44,7 @@
 best libray count, timing data.
 '''
 def GenerateBarChart(results, libraries, fileName, bestlib="mlpack", 
-    backgroundColor="#FFFFFF"):
+    backgroundColor="#FFFFFF", textColor="#6e6e6e"):
   # Bar chart settings.
   lineWidth = 0.1
   barWidth = 0.15
@@ -161,8 +161,8 @@
   plt.xticks(legendIndex , list(timingData.keys()), rotation=30, ha='right')
 
   # Set the color and the font of the x-axis and y-axis label.
-  ax.tick_params(axis='both', which='major', labelsize=8, labelcolor="#6e6e6e")
-  ax.tick_params(axis='both', which='minor', labelsize=6, labelcolor="#6e6e6e")
+  ax.tick_params(axis='both', which='major', labelsize=8, labelcolor=textColor)
+  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', 
@@ -170,10 +170,10 @@
     shadow=False, ncol=6, fontsize=8)
   lgd.get_frame().set_linewidth(0)
   for label in lgd.get_texts():
-    label.set_color("#6e6e6e")
+    label.set_color(textColor)
 
   # Set axis labels.
-  plt.ylabel("time [s]", color="#6e6e6e")
+  plt.ylabel("time [s]", color=textColor)
 
   # Save the bar chart.
   fig.tight_layout()
@@ -205,7 +205,7 @@
 @prama windowHeight - The height of the chart.
 '''
 def GenerateSingleLineChart(data, fileName, backgroundColor="#FFFFFF", 
-    windowWidth=8.1, windowHeight=1.3):
+    windowWidth=8.1, windowHeight=1.3, textColor="#6e6e6e"):
   
   # Generate a list of scalar values. Use the privious or next elemnt to fill 
   # the gap.
@@ -221,60 +221,59 @@
       i += 1
     return data
 
-  if not CheckFileAvailable(fileName):
-    # Line chart settings.
-    lineWidth = 1.5
-    opacity = 0.9
-    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=100)
-    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)
-
-    # Set ticks for the x-axis.
-    myLocator = mticker.MultipleLocator(1)
-    ax.xaxis.set_major_locator(myLocator)
-
-    data = NormalizeData(data)
-
-    # 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
+  # Line chart settings.
+  lineWidth = 1.5
+  opacity = 0.9
+  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=100)
+  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)
+
+  # Set ticks for the x-axis.
+  myLocator = mticker.MultipleLocator(1)
+  ax.xaxis.set_major_locator(myLocator)
+
+  data = NormalizeData(data)
+
+  # 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)))
+  # Create the data for the x-axis.
+  X = list(range(len(data)))
+
+  # Plot the line chart.
+  plt.plot(X, data, color=colors[0], alpha=opacity, linewidth=1.7)
 
-    # Plot the line chart.
-    plt.plot(X, data, color=colors[0], alpha=opacity, linewidth=1.7)
+  # Set the color and the font of the x-axis and y-axis labels.
+  ax.tick_params(axis='both', which='major', labelsize=8, labelcolor=textColor)
+  ax.tick_params(axis='both', which='minor', labelsize=6, labelcolor=textColor)
 
-    # 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")
-
-    # Set axis labels.
-    plt.ylabel("time [s]", color="#6e6e6e")
-    plt.xlabel("benchmark build", color="#6e6e6e")
-
-    # Save the line chart.
-    fig.tight_layout()
-    fig.savefig(fileName, bbox_inches='tight', facecolor=fig.get_facecolor(), 
-        edgecolor='none', dpi=100)
-    plt.close()
+  # Set axis labels.
+  plt.ylabel("time [s]", color=textColor)
+  plt.xlabel("benchmark build", color=textColor)
+
+  # Save the line chart.
+  fig.tight_layout()
+  fig.savefig(fileName, bbox_inches='tight', facecolor=fig.get_facecolor(), 
+      edgecolor='none', dpi=100)
+  plt.close()
 
 '''
 Generate a memory chart with the specified informations.
@@ -283,75 +282,74 @@
 @param fileName - The filename of the memory chart.
 @param backgroundColor - The color of the image background.
 '''
-def CreateMassifChart(massiflogFile, fileName, backgroundColor="#FFFFFF"):
-  if not CheckFileAvailable(fileName):
-    lineWidth = 1.5
-    opacity = 0.9
-    windowWidth = 8.1
-    windowHeight = 1.3
-    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=100)
-    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.
-    try:
-      with open(massiflogFile, "r") as fid:
-        content = fid.read()
-    except IOError as e:
-      Log.Fatal("Exception: " + str(e))
-      return
-
-    # Parse the massif logfile.
-    memHeapB = [(int(i) / 1024) + 0.0001 for i in re.findall(r"mem_heap_B=(\d*)", content)]
-    memHeapExtraB = [(int(i) / 1024) + 0.0001 for i in  re.findall(r"mem_heap_extra_B=(\d*)", content)]
-    memStackB = [(int(i) / 1024) + 0.0001 for i in  re.findall(r"mem_stacks_B=(\d*)", content)]
-
-    # Plot the memory information.
-    X = list(range(len(memHeapExtraB)))
-    X = [x+0.0001 for x in X]
-    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)
-
-    # Set axis labels.
-    plt.ylabel("memory [KB]", color="#6e6e6e")
-    plt.xlabel("snapshot", color="#6e6e6e")
-
-    # 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")
+def CreateMassifChart(massiflogFile, fileName, backgroundColor="#FFFFFF", textColor="6e6e6e"):
+  lineWidth = 1.5
+  opacity = 0.9
+  windowWidth = 8.1
+  windowHeight = 1.3
+  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=100)
+  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.
+  try:
+    with open(massiflogFile, "r") as fid:
+      content = fid.read()
+  except IOError as e:
+    Log.Fatal("Exception: " + str(e))
+    return
+
+  # Parse the massif logfile.
+  memHeapB = [(int(i) / 1024) + 0.0001 for i in re.findall(r"mem_heap_B=(\d*)", content)]
+  memHeapExtraB = [(int(i) / 1024) + 0.0001 for i in  re.findall(r"mem_heap_extra_B=(\d*)", content)]
+  memStackB = [(int(i) / 1024) + 0.0001 for i in  re.findall(r"mem_stacks_B=(\d*)", content)]
+
+  # Plot the memory information.
+  X = list(range(len(memHeapExtraB)))
+  X = [x+0.0001 for x in X]
+  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=textColor)
+  ax.tick_params(axis='both', which='minor', labelsize=6, labelcolor=textColor)
+
+  # 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)
+
+  # Set axis labels.
+  plt.ylabel("memory [KB]", color=textColor)
+  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', 
+    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', 
-      facecolor=fig.get_facecolor(), edgecolor='none', format='png', dpi=100)
-    plt.close()
+  # Save the memory chart.
+  fig.tight_layout()
+  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