예제 #1
0
def stats_info(fname):
    tasks, machines, configs, pwrcap, mintime, maxtime, rects = fileio.file2rects(fname)
    sumarea = [0]
    idlearea = [0]
    def addAreas(i, j, k, x1, x2, y1, y2):
        sumarea[0] += (x2-x1) * (y2 - y1)
        if(i == tasks):
            idlearea[0] += (x2-x1) * (y2 - y1)
        
    
    rectangles.drawrects(rects, addAreas)
    
    totalarea = ((maxtime-mintime) * pwrcap)
    wasted = totalarea - sumarea[0]
    
    return maxtime, totalarea, sumarea[0], wasted, idlearea[0]
예제 #2
0
def draw(fname, dir, subdir, imgName, cols, idlecol):
    fig = init_figure()
    ax = fig.add_subplot(111)
    
    tasks, machines, configs, pwrcap, mintime, maxtime, rects = fileio.file2rects(fname)    
    
    def drawTask(i, j, k, x1, x2, y1, y2):
        
        if(i < tasks):
            col = cols[i % len(cols)]
            add_rectangle(ax, x1, y1, (x2-x1), (y2-y1), col)
        else:
            add_idle_rectangle(ax, x1, y1, (x2-x1), (y2-y1), idlecol)
        
    rectangles.drawrects(rects, drawTask)
    ax.axhline(y = pwrcap, c = 'r', linewidth=1, zorder=5)
    plt.plot([maxtime,maxtime],[0,pwrcap], '0.75')
    plt.ylabel("Power")
    plt.xlabel("Time")
    plt.title(fname.split('-')[0]+" policy, power cap: "+fname.split('-')[1]+", #tasks: "+fname.split('-')[2], fontsize = 14)
    
    saveDir = os.path.join("imgOutput", dir, subdir)
    create_dir(saveDir)
    save_figure(fig, imgName, saveDir)