ninestein benchmarks:

  • Intel Xeon E5520 CPU @ 2.27 GHz
  • CPython 2.7.3
  • numpy 1.6.1

In [1]:
import re

# load measurements

class Benchmark: pass

bms = []

for line in open("../measurements/benchmark/benchmark-ninestein.dat"):
        g = re.match("(.*\))\s+(\d+)\s+([0-9.]+)", line)
        if not g:
            print "corrupted:", line
            continue 
            
        bm = Benchmark()
        
        bm.method = g.group(1)
        bm.Ns = int(g.group(2))
        bm.time = float(g.group(3))
        
        bms.append(bm)

In [2]:
# sort SCF last

def k(bm):
    if 'SCF' in bm.method:
        return 1
    else:
        return 0

bms.sort(key=k)

In [6]:
from matplotlib import cm

Ns = [25000, 50000, 100000]

cmap = cm.get_cmap('gist_rainbow')

time = []

for Ns1 in Ns:
    time1 = []
    methods = []
    left = []
    color = []
    left1 = 0
    i = 0
    j = 0
    n = 0
    for bm in bms:        
        if bm.Ns == Ns1:
            m = bm.method
            m = m.replace('(', ' ').replace(')', '')
            m = m.replace('EnergyDetector', 'ED')
            m = m.replace('Detector', '')
            m = re.sub("Np=(\d+), L=\d+", r"$N'=\1$", m)
            m = re.sub("L=(\d+)", r"$L=\1$", m)
            
            c = cmap(i/7. + j*0.007)
            #color.append(c)
            color.append((.85,.85,.85))
            color.append("#d9cbc3")
            
            methods.append(m)
            
            time1.append(bm.time)
            
            left.append(left1)
            left1 += 1
            j += 1
            
            if n == 0 or n % 4 == 0 or n == 30:
                left1 += .9
                i += 1
                j = 0
            n += 1
            
    time.append(time1)
    
left = array(left)
time = array(time)

In [7]:
def plot_time(time, Ns):
    height = time[:]/time[0]
    #height[1] = .01
    #height[-2] = 1
    
    figure(figsize=(13, 5))

    bottom = 1
    bar(left, height-bottom, color=color, bottom=bottom)
    xticks(left+.4, methods, rotation=60, horizontalalignment='right')
    xlim(-.5, left1+.5-.9)
    gca().set_yscale('log')
    ylim(1e0, 1e6)
    
    for x, y in zip(left, height):
        text(x+.4, y*1.5, "%.0f" % y, horizontalalignment="center", verticalalignment="bottom", rotation=70, backgroundcolor='w')
    
    ylabel("$t_{CPU}$ [relative to energy detector]")
    title("$t=25.0$ms ($N_s = %d$ksamples)" % (Ns/1e3,))
    
    tight_layout()
    grid()
    
    # legend
    yi = 5e5
    for si, ei, label in [[0,1,"energy"], 
                          [1,17,"covariance"], 
                          [17,29,"eigenvalue"],
                          [29,31,""], 
                          ]:
        
        x1 = left[si]
        x2 = left[ei-1]+.8
        
        plot([x1,x2], [yi,yi], 'k')
        plot([x1,x1], [yi/.8,yi*.8], 'k')
        plot([x2,x2], [yi/.8,yi*.8], 'k')
        
        #print x1, x2
        
        text((x1+x2)/2., yi*.7, label, horizontalalignment="center", verticalalignment="top", backgroundcolor='w')
        
    text(34.2, yi*.4, "cyclo-\nstationary", horizontalalignment="center", verticalalignment="top", backgroundcolor='w')    
    plot([36.0, 34.8], [yi*.7, yi*.4], 'k')
        
        
plot_time(time[0], Ns[0])
#savefig("time_comparison_25ms.png", dpi=120)
savefig("time_comparison_25ms.eps")



In [49]:
plot_time(time[1], Ns[1])
#savefig("time_comparison_13ms.png", dpi=120)



In [50]:
plot_time(time[2], Ns[2])
#savefig("time_comparison_10ms.png", dpi=120)



In [51]:
methods


Out[51]:
['ED ',
 'CAV $L=5$',
 'CAV $L=10$',
 'CAV $L=15$',
 'CAV $L=20$',
 'CFN $L=5$',
 'CFN $L=10$',
 'CFN $L=15$',
 'CFN $L=20$',
 'MAC $L=5$',
 'MAC $L=10$',
 'MAC $L=15$',
 'MAC $L=20$',
 'MME $L=5$',
 'MME $L=10$',
 'MME $L=15$',
 'MME $L=20$',
 'EME $L=5$',
 'EME $L=10$',
 'EME $L=15$',
 'EME $L=20$',
 'AGM $L=5$',
 'AGM $L=10$',
 'AGM $L=15$',
 'AGM $L=20$',
 'MET $L=5$',
 'MET $L=10$',
 'MET $L=15$',
 'MET $L=20$',
 "SCF $N'=64$",
 "SCF $N'=128$"]

In [52]:
methods2 = [ methods[0] ] + methods[1:5] + methods[-2:]
print methods2


['ED ', 'CAV $L=5$', 'CAV $L=10$', 'CAV $L=15$', 'CAV $L=20$', "SCF $N'=64$", "SCF $N'=128$"]

In [53]:
import re

nops = []

Ns1 = Ns[0]

for method in methods2:
    
    if method == 'ED ':
        nops1 = Ns1
    elif method.startswith('SCF'):
        g = re.search("N'=(\d+)", method)
        Np = float(g.group(1))
        L = Np/4.
        P = Ns1/L
        
        nops1 = 2*(Np**2.)*P*log2(P)
        print nops1
    elif 'L=' in method:
        g = re.search("L=(\d+)", method)
        L = float(g.group(1))
        
        nops1 = L*Ns1
    else:
        nops1 = 0
        
    nops.append(nops1)
    
nops = array(nops)


135803398.073
246006796.146

In [54]:
nops


Out[54]:
array([  2.50000000e+04,   1.25000000e+05,   2.50000000e+05,
         3.75000000e+05,   5.00000000e+05,   1.35803398e+08,
         2.46006796e+08])

In [55]:
def plot_nops(left, nops, Ns):
    height = nops
    relheight = nops / nops[0]
    
    figure(figsize=(6, 5))
    #print gcf().get_size_inches()

    k = 1.2
    bottom = 1
    bar(left*k, height-bottom, color=color[:5] + color[-2:], bottom=bottom)
    xticks((left*k+.4), methods2, rotation=60, horizontalalignment='right')
    xlim(-.5, (left*k)[-1]+.5+.7*k)
    gca().set_yscale('log')
    ylim(1e4, 1e10)
    
    for x, y, yr in zip(left*k, height, relheight):
        if y > 1e6:
            s = "%.0fM\n(%.0f)" % (y/1e6, yr)
        else:
            s = "%.0fk\n(%.0f)" % (y/1e3, yr)
        text(x+.4, y*1.5, s, horizontalalignment="center", verticalalignment="bottom", rotation=70, backgroundcolor='w')
    
    ylabel("approx. number of floating point multiplications")
    title("$t=25.0$ms ($N_s = %d$ksamples)" % (Ns/1e3,))
    
    tight_layout()
    grid()
    
    # legend
    yi = 5e9
    for si, ei, label in [[0,1,"energy"], 
                          [1,5,"covariance"],
                          [5,7,""], 
                          ]:
        
        x1 = left[si]*k
        x2 = left[ei-1]*k+.8
        
        plot([x1,x2], [yi,yi], 'k')
        plot([x1,x1], [yi/.8,yi*.8], 'k')
        plot([x2,x2], [yi/.8,yi*.8], 'k')
        
        print x1, x2
        
        text((x1+x2)/2., yi*.7, label, horizontalalignment="center", verticalalignment="top", backgroundcolor='w')
        
    text(7., yi*.4, "cyclo-\nstationary", horizontalalignment="center", verticalalignment="top", backgroundcolor='w')    
    plot([8,7.5], [yi*.7, yi*.4], 'k')
    
plot_nops(left[:7], nops[:7], Ns[0])
#savefig("nops_comparison_25ms.eps")


0.0 0.8
2.28 6.68
8.16 10.16

In [11]: