Changeset 107


Ignore:
Timestamp:
06/01/10 08:38:02 (3 years ago)
Author:
faltet
Message:

More beautifications on plotting script. This should be ready by now.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/bench/plot-speeds.py

    r99 r107  
     1"""Script for plotting the results of the 'suite' benchmark. 
     2Invoke without parameters for usage hints. 
     3 
     4:Author: Francesc Alted 
     5:Date: 2010-06-01 
     6""" 
     7 
     8import matplotlib as mpl 
    19from pylab import * 
     10 
     11MB_ = 1024*1024 
     12NCHUNKS = 128    # keep in sync with bench.c 
    213 
    314linewidth=2 
     
    920def get_values(filename): 
    1021    f = open(filename) 
    11     values = {} 
     22    values = {"memcpyw": [], "memcpyr": []} 
    1223 
    1324    for line in f: 
     
    1526            tmp = line.split('-->')[1] 
    1627            nthreads, size, elsize, sbits = [int(i) for i in tmp.split(', ')] 
     28            values["size"] = size * NCHUNKS / MB_; 
     29            values["elsize"] = elsize; 
     30            values["sbits"] = sbits; 
    1731            # New run for nthreads 
    1832            (ratios, speedsw, speedsr) = ([], [], []) 
    1933            # Add a new entry for (ratios, speedw, speedr) 
    2034            values[nthreads] = (ratios, speedsw, speedsr) 
    21             print "-->", nthreads, size, elsize, sbits 
     35            #print "-->", nthreads, size, elsize, sbits 
    2236        elif line.startswith('memcpy(write):'): 
    2337            tmp = line.split(',')[1] 
    2438            memcpyw = float(tmp.split(' ')[1]) 
    25             print "memcpyw-->", memcpyw 
     39            values["memcpyw"].append(memcpyw) 
    2640        elif line.startswith('memcpy(read):'): 
    2741            tmp = line.split(',')[1] 
    2842            memcpyr = float(tmp.split(' ')[1]) 
    29             print "memcpyr-->", memcpyr 
     43            values["memcpyr"].append(memcpyr) 
    3044        elif line.startswith('comp(write):'): 
    3145            tmp = line.split(',')[1] 
     
    5064    title(gtitle) 
    5165    #ylim(0, 10000) 
     66    ylim(0, None) 
    5267    grid(True) 
    5368 
     
    5570#     legends = [l.replace('-', ' ') for l in legends] 
    5671    #legend([p[0] for p in plots], legends, loc = "upper left") 
    57     legend([p[0] for p in plots], legends, loc = "best") 
     72    legend([p[0] for p in plots 
     73            if not isinstance(p, mpl.lines.Line2D)], 
     74           legends, loc = "best") 
    5875 
    5976 
    6077    #subplots_adjust(bottom=0.2, top=None, wspace=0.2, hspace=0.2) 
    6178    if outfile: 
     79        print "Saving plot to:", outfile 
    6280        savefig(outfile) 
    6381    else: 
     
    93111    tit = None 
    94112    cspeed = False 
     113    gtitle = "Decompression speed" 
    95114    dspeed = True 
    96115    yaxis = "No axis name" 
    97     gtitle = "Please set a title!" 
    98116 
    99117    # Get the options 
     
    114132    filename = pargs[0] 
    115133 
    116     if tit: 
    117         gtitle = tit 
    118  
    119134    plots = [] 
    120135    legends = [] 
    121136    nthreads, values = get_values(filename) 
     137    #print "Values:", values 
     138 
     139    if tit: 
     140        gtitle = tit 
     141    else: 
     142        gtitle += " (%(size).1f MB, %(elsize)d bytes, %(sbits)d bits)" % values 
     143 
    122144    for nt in range(1, nthreads+1): 
    123         print "Values for %s threads --> %s" % (nt, values) 
     145        #print "Values for %s threads --> %s" % (nt, values[nt]) 
    124146        (ratios, speedw, speedr) = values[nt] 
    125147        if cspeed: 
     
    137159        legends.append("%d threads" % nt) 
    138160 
     161    # Add memcpy lines 
     162    if cspeed: 
     163        mean = sum(values["memcpyw"]) / nthreads 
     164        message = "memcpy (write to memory)" 
     165    else: 
     166        mean = sum(values["memcpyr"]) / nthreads 
     167        message = "memcpy (read from memory)" 
     168    plot_ = axhline(mean, linewidth=3, linestyle='-.', color='black') 
     169    text(0.5, mean+50, message) 
     170    plots.append(plot_) 
    139171    show_plot(plots, yaxis, legends, gtitle) 
     172 
     173 
Note: See TracChangeset for help on using the changeset viewer.