view paper/file/benchmark/bar.py @ 59:c72f0d0eb28a

update slide
author Ken Miyahira <e175733@ie.u-ryukyu.ac.jp>
date Mon, 15 Feb 2021 16:18:55 +0900
parents 71e1425687f3
children
line wrap: on
line source

import matplotlib.pyplot as plt
import subprocess

def getData():
    x, y = [], []
    print("データ読み込み")
    x = [1, 2, 3]
    label = ["Docker", "ie-podman", "Singularity", "Podman"]
    realtime = [59.52, 54.24, 53.59, 199.40]
    usertime = [7.52, 13.22, 26.10, 23.18]
    systime  = [7.89, 8.69, 3.00, 23.78]

    name = input("GraphName: ")
    xlabel = input("xlabel: ")
    ylabel = input("ylabel: ")
    xr = input("Xrange: ")
    xr = xr.split(" ")
    yr = input("Yrange: ")
    yr = yr.split(" ")
    # 画像出力
    print("画像出力")
    plot_graph(name,x,realtime,usertime,systime,float(xr[0]),float(xr[1]),float(yr[0]),float(yr[1]),xlabel,ylabel,label)
    return name
    
def plot_graph(name,x,realtime,usertime,systime,sx,ex,sy,ey,xlabel,ylabel,label):
    plt.xlim(sx,ex)
    plt.xlabel(str(xlabel))
    plt.ylim(sy,ey)
    plt.ylabel(str(ylabel))
    realx = [1, 2, 3, 4]
    userx = [1.3,2.3,3.3,4.3]
    sysx = [1.6,2.6,3.6,4.6]
    plt.bar(realx, realtime, label="real", width=0.3, align="center")
    plt.bar(userx, usertime, label="user", width=0.3, align="center")
    plt.bar(sysx, systime, label="sys", width=0.3, align="center")
    plt.legend()
    plt.xticks([1.25, 2.25, 3.25, 4.25], label)
    plt.savefig("./pdf/"+str(name)+".pdf")
    plt.delaxes()

def openGraph(name):
    cmd = ["open", "./pdf/"+str(name)+".pdf"]
    subprocess.check_call(cmd)

if __name__ == "__main__":
    name = getData()
    if(input("画像を表示しますか(Y or N): ")=="y"):
        openGraph(name)