[pypy-svn] r59588 - pypy/build/benchmem

fijal at codespeak.net fijal at codespeak.net
Fri Oct 31 12:31:20 CET 2008


Author: fijal
Date: Fri Oct 31 12:31:18 2008
New Revision: 59588

Modified:
   pypy/build/benchmem/report_graphic.py
Log:
A bit more progress on drawing graphs


Modified: pypy/build/benchmem/report_graphic.py
==============================================================================
--- pypy/build/benchmem/report_graphic.py	(original)
+++ pypy/build/benchmem/report_graphic.py	Fri Oct 31 12:31:18 2008
@@ -14,8 +14,15 @@
 SHOW = False
 
 def process_baseint_sizes(results):
-    lgt = len(results)
-    ind = numpy.array([float(i)/lgt for i in range(lgt)])
+    """ This function plots base interpreter sizes of various interpreters
+    with bars specifying:
+
+    * heap private
+    * ip code
+    * ip data
+    * private rest
+    """
+    
     heap_private = numpy.array([result.snapshot.filter(group=HEAP).private
                     for result in results])
     ip_code = numpy.array([result.snapshot.filter(group=result.executable,
@@ -30,9 +37,12 @@
                         results])
     return plot_baseint_sizes(heap_private, ip_code, ip_data, rest, results)
 
-def plot_basint_sizes(heap_private, ip_code, ip_data, rest, results):
+def plot_baseint_sizes(heap_private, ip_code, ip_data, rest, results):
     # XXX add axes scaling
+    pylab.clf()
     WIDTH = .1
+    lgt = len(results)
+    ind = numpy.array([float(i)/lgt for i in range(lgt)])
     p0 = pylab.bar(ind, heap_private, WIDTH, color='r')
     p1 = pylab.bar(ind, ip_code, WIDTH, color='b', bottom=heap_private)
     p2 = pylab.bar(ind, ip_data, WIDTH, color='w', bottom=heap_private+ip_code)
@@ -44,9 +54,17 @@
     pylab.savefig(BASE + "base_size.ps")
     if SHOW:
         pylab.show()
-    return ip_code + ip_data + heap_private + rest
+    res = {}
+    for i, value in enumerate(ip_code + ip_data + heap_private + rest):
+        res[results[i].executable] = value
+    return res
 
 def process_objsizes(resultset):
+    """ This function creates series of graphs for showing incremental
+    private memory consumed for object allocation (without base interpreter
+    size)
+    """
+    
     def incremental_private(result):
         return (result.snapshots[1].heap_private() -
                 result.snapshots[0].heap_private())
@@ -65,32 +83,55 @@
     # XXX implement saner colorization
     colors = ['r', 'g', 'b', 'black', 'white', 'cyan', 'magenta', 'yellow'
               'purple', 'grey']
-    lgt = len(benchresults[0])
-    baseindices = numpy.array([float(i)/lgt for i in range(lgt)])
-    basewidth = (baseindices[1] - baseindices[0])
-    skip = (basewidth * .5) / len(benchresults)
-    bars = []
-    for i, benchresult in enumerate(benchresults):
-        bars.append(pylab.bar(baseindices + skip * i, benchresult, skip,
-                              color=colors[i]))
-    # XXX I'm completely unsure how to make a reasonable
-    pylab.legend([bar[0] for bar in bars], executables)
-    pylab.savefig(BASE + "objsizes.ps")
-    if SHOW:
-        pylab.show()
+
+    benchresults = numpy.array(benchresults)
+    names = numpy.array(names)
+    
+    split = 10 # max number of bars per graph
+    for view in range(len(benchresults[0])/split):
+        start = view * split
+        end = min((view + 1)*split, len(benchresults[0]))
+        results = benchresults[:, start:end]
+        pylab.clf()
+        lgt = len(results[0])
+        baseindices = numpy.array([float(i)/lgt for i in range(lgt)])
+        basewidth = (baseindices[1] - baseindices[0])
+        skip = (basewidth * .5) / len(benchresults)
+        bars = []
+        for i, benchresult in enumerate(results):
+            bars.append(pylab.bar(baseindices + skip * i, benchresult, skip,
+                                  color=colors[i]))
+        pylab.legend([bar[0] for bar in bars], executables)
+        # XXX a lot of magic is required to provide a reasonable
+        #     set of non-overlapping xticks
+        pylab.xticks(baseindices + basewidth/4, ['B%d' % i for i in
+                                            range(start, end)])
+        pylab.savefig(BASE + "objsizes_%d.ps" % view)
+        if SHOW:
+            pylab.show()
 
 def process_appprofiles(resultset, totals):
-    pass
-    #for name, results in resultset.filter(benchtype="appprofiles").getname2results():
-    #    for result in results:
-    #        lgt = len(result.snapshots)
-    #        x = [float(i)/lgt for i in range(lgt)]
-    #        y = [snapshot.private for snapshot in result.snapshots]
-    #        pylab.title(name)
-    #        pylab.plot(x, y)
-    #    
-    #    if SHOW:
-    #        pylab.show()
+    """ This function plots incremental memory consumption of app benchmarks
+    (withou interpreter size) versus time (in %s)
+    """
+    
+    pylab.clf()
+    for name, results in resultset.filter(benchtype="appprofiles").getname2results():
+        plots = []
+        for result in results:
+            lgt = len(result.snapshots)
+            x = [(float(i)/lgt)*100 for i in range(lgt)]
+            y = [snapshot.private - totals[result.executable]
+                 for snapshot in result.snapshots]
+            pylab.title(name)
+            plots.append(pylab.plot(x, y))
+
+        pylab.legend(plots, [result.executable for result in results])
+        pylab.xlabel("time (%)")
+        pylab.ylabel("incremental private memory consumption")
+        pylab.savefig(BASE + 'appprofiles_%s.ps' % name)
+        if SHOW:
+            pylab.show()
 
 
 def main(filename):



More information about the Pypy-commit mailing list