Esempio n. 1
0
def Over(over_1, over_2, over_3):
    mplot.plotPrepareLogLog()

    o3 = mplot.plotMMA(
        over_3, 'round_wall', color3_light, 0,
        dict(label='32 Machines',
             linestyle='-',
             marker='s',
             color=color3_dark,
             zorder=3))

    o2 = mplot.plotMMA(
        over_2, 'round_wall', color2_light, 0,
        dict(label='16 Machines',
             linestyle='-',
             marker='^',
             color=color2_dark,
             zorder=3))

    o1 = mplot.plotMMA(
        over_1, 'round_wall', color1_light, 0,
        dict(label='8 Machines',
             linestyle='-',
             marker='o',
             color=color1_dark,
             zorder=3))

    xmin, xmax, ymin, ymax = CSVStats.get_min_max(o1, o2, o3)
    plt.ylim(ymin, ymax)
    plt.xlim(xmin, xmax * 1.2)
    plt.ylabel('Seconds per round')

    plt.legend(loc=u'lower right')
    mplot.plotEnd()
Esempio n. 2
0
def PlotMultiBF(*values_bf):
    mplot.plotPrepareLogLog(2, 0)
    plotbf = []
    pparams = [[color1_light, color1_dark, 'o'],
               [color2_light, color2_dark, 's'],
               [color3_light, color3_dark, '^'],
               [color4_light, color4_dark, '.']]

    for i, value in enumerate(values_bf):
        label = str(int(value.columns['Peers'][0])) + " Peers"
        c1, c2, m = pparams[i]
        plotbf.append(
            mplot.plotMMA(
                value, 'round_wall', c1, 0,
                dict(label=label, linestyle='-', marker=m, color=c2,
                     zorder=3)))

    xmin, xmax, ymin, ymax = CSVStats.get_min_max(*plotbf)
    plt.ylim(ymin, ymax)
    plt.xlim(xmin, xmax * 1.2)
    plt.ylabel('Seconds per round')
    plt.xlabel('Branching factor')

    plt.legend(loc=u'upper right')
    mplot.plotEnd()
Esempio n. 3
0
def plotAvgMM(co, jvss, naive, nt):
    mplot.plotPrepareLogLog()

    nt = mplot.plotMMA(ntree, 'round_wall', color4_light, 0,
                      dict(label='Ntree', linestyle='-', marker='v', color=color4_dark, zorder=3))
    # mplot.arrow("{:.1f} sec      ".format(mplot.avg[-2]), x[-2], 4, color3_dark)
    # mplot.arrow("      {:.0f} sec".format(mplot.avg[-1]), x[-1], 4, color3_dark)

    j = mplot.plotMMA(jvss, 'round_wall', color2_light, 0,
                      dict(label='JVSS', linestyle='-', marker='^', color=color2_dark, zorder=3))
    #j_p = jvss.get_values('round_wall')
    #plt.plot(j_p.x, j_p.avg, label="JVSS", color=color2_dark, marker='^')
    #mplot.arrow("{:.1f} sec      ".format(j_p.avg[-2]), j_p.x[-2], 4, color2_dark)
    #mplot.arrow("      {:.0f} sec".format(j_p.avg[-1]), j_p.x[-1], 8, color2_dark)

    na = mplot.plotMMA(naive, 'round_wall', color3_light, 0,
                       dict(label='Naive', linestyle='-', marker='s', color=color3_dark, zorder=3))
    na_p = naive.get_values('round_wall')
    #mplot.arrow("{:.1f} sec      ".format(na_p.avg[8]), na_p.x[8], 4, color3_dark)
    mplot.arrow("      {:.0f} sec".format(na_p.avg[9]), na_p.x[9], 8, color3_dark)

    co = mplot.plotMMA(cothority, 'round_wall', color1_light, 4,
                       dict(label='Cothority', linestyle='-', marker='o', color=color1_dark, zorder=5))

    # Make horizontal lines and add arrows for JVSS
    xmin, xmax, ymin, ymax = CSVStats.get_min_max(na, co)
    plt.ylim(ymin, 8)
    plt.xlim(xmin, xmax * 1.2)
    plt.ylabel('Seconds per round')

    plt.legend(loc=u'lower right')
    mplot.plotEnd()
Esempio n. 4
0
def plotAvg(co, jvss, naive, nt):
    mplot.plotPrepareLogLog()

    j_p = jvss.get_values('round_wall')
    plt.plot(j_p.x, j_p.avg, label="JVSS", color=color2_dark, marker='^')

    na_p = naive.get_values('round_wall')
    plt.plot(na_p.x, na_p.avg, label="Naive", color=color3_dark, marker='s')
    #mplot.arrow("      {:.0f} sec".format(na_p.avg[9]), na_p.x[9], 8, 1, color3_dark)

    nt_p = nt.get_values('round_wall')
    plt.plot(nt_p.x, nt_p.avg, label="Ntree", color=color4_dark, marker='v')

    co_p = cothority.get_values('round_wall')
    plt.plot(co_p.x,
             co_p.avg,
             label="Cothority",
             color=color1_dark,
             marker='o')

    # Make horizontal lines and add arrows for JVSS
    xmin, xmax, ymin, ymax = CSVStats.get_min_max(j_p, na_p, nt_p, co_p)
    plt.ylim(ymin, 8)
    plt.xlim(xmin, 1024 * 1.2)
    plt.ylabel('Seconds per round')

    plt.legend(loc=u'lower right')
    mplot.plotEnd()
Esempio n. 5
0
def plotData(data,
             name,
             xlabel="Number of witnesses",
             ylabel="Signing round latency in seconds",
             xticks=[],
             loglog=[2, 2],
             xname="hosts",
             legend_pos="lower right",
             yminu=0,
             ymaxu=0,
             xminu=0,
             xmaxu=0,
             title="",
             read_plots=True):
    mplot.plotPrepareLogLog(loglog[0], loglog[1])
    if read_plots:
        plots = read_csvs_xname(xname, *data[0])
    else:
        plots = data[0]

    ranges = []
    data_label = []
    plot_show(name)

    for index, label in enumerate(data[1]):
        data_label.append([plots[index], label])
        ranges.append(
            mplot.plotMMA(
                plots[index], 'round_wall', colors[index][0], 4,
                dict(label=label,
                     linestyle='-',
                     marker='o',
                     color=colors[index][1],
                     zorder=5)))

    # Make horizontal lines and add arrows for JVSS
    xmin, xmax, ymin, ymax = CSVStats.get_min_max(*ranges)
    if yminu != 0:
        ymin = yminu
    if ymaxu != 0:
        ymax = ymaxu
    if xminu != 0:
        xmin = xminu
    if xmaxu != 0:
        xmax = xmaxu
    plt.ylim(ymin, ymax)
    plt.xlim(xmin, xmax)
    plt.xlabel(xlabel)
    plt.ylabel(ylabel)

    plt.legend(loc=legend_pos)
    plt.axes().xaxis.grid(color='gray', linestyle='dashed', zorder=0)
    if len(xticks) > 0:
        ax = plt.axes()
        ax.set_xticks(xticks)
    if title != "":
        plt.title(title)
    mplot.plotEnd()
    return data_label
Esempio n. 6
0
def plotData(data, name,
             xlabel="Time since last update", ylabel="Bandwidth",
             xticks=[], loglog=[0, 0], xname="time",
             legend_pos="lower right",
             yname="bandwidth",
             yminu=0, ymaxu=0,
             xminu=0, xmaxu=0,
             title="", read_plots=True,
             restart_x=False):
    mplot.plotPrepareLogLog(loglog[0], loglog[1])
    if read_plots:
        plots = read_csvs_xname(xname, *data[0])
    else:
        plots = data[0]

    ranges = []
    data_label = []
    plot_show(name)
    subx = 0
    if restart_x:
        subx = plots[0].columns[xname][0]

    for index, label in enumerate(data[1]):
        data_label.append([plots[index], label])
        # plots[index].print_short()
        if restart_x:
            print subx
            plots[index].column_add(xname, -subx)
            plots[index].get_values("time")

        ranges.append(
            mplot.plotMMA(plots[index], yname, colors[index][0], 4,
                          dict(label=label, linestyle='-', marker='.',
                               color=colors[index][1], zorder=5)))

    # Make horizontal lines and add arrows for JVSS
    xmin, xmax, ymin, ymax = CSVStats.get_min_max(*ranges)
    if yminu != 0:
        ymin = yminu
    if ymaxu != 0:
        ymax = ymaxu
    if xminu != 0:
        xmin = xminu
    if xmaxu != 0:
        xmax = xmaxu
    plt.ylim(ymin, ymax)
    plt.xlim(xmin, xmax)
    plt.xlabel(xlabel)
    plt.ylabel(ylabel)

    plt.legend(loc=legend_pos)
    plt.axes().xaxis.grid(color='gray', linestyle='dashed', zorder=0)
    if len(xticks) > 0:
        ax = plt.axes()
        ax.set_xticks(xticks)
    if title != "":
        plt.title(title)
    mplot.plotEnd()
    return data_label
Esempio n. 7
0
def PlotBF(values_bf):
    mplot.plotPrepareLogLog(2, 0)

    plotbf = mplot.plotMMA(values_bf, 'round_wall', color1_light, 0,
                           dict(label='4096 Peers', linestyle='-', marker='o', color=color2_dark, zorder=3))

    xmin, xmax, ymin, ymax = CSVStats.get_min_max(plotbf)
    plt.ylim(ymin, ymax)
    plt.xlim(xmin, xmax * 1.2)
    plt.ylabel('Seconds per round')
    plt.xlabel('Branching factor')

    plt.legend(loc=u'upper right')
    mplot.plotEnd()
Esempio n. 8
0
def PlotStamp(stamp):
    mplot.plotPrepareLogLog(10, 0)

    plotbf = mplot.plotMMA(stamp, 'round_wall', color1_light, 0,
                           dict(label='4096 Peers', linestyle='-', marker='o', color=color2_dark, zorder=3))

    xmin, xmax, ymin, ymax = CSVStats.get_min_max(plotbf)
    plt.ylim(ymin, ymax)
    plt.xlim(xmin, xmax * 1.2)
    plt.ylabel('Seconds per round')
    plt.xlabel('Stamping rate [1/s]')

    plt.legend(loc=u'upper right')
    mplot.plotEnd()
Esempio n. 9
0
def Over(over_1, over_2, over_3):
    mplot.plotPrepareLogLog()

    o3 = mplot.plotMMA(over_3, 'round_wall', color3_light, 0,
                       dict(label='32 Machines', linestyle='-', marker='s', color=color3_dark, zorder=3))

    o2 = mplot.plotMMA(over_2, 'round_wall', color2_light, 0,
                       dict(label='16 Machines', linestyle='-', marker='^', color=color2_dark, zorder=3))

    o1 = mplot.plotMMA(over_1, 'round_wall', color1_light, 0,
                       dict(label='8 Machines', linestyle='-', marker='o', color=color1_dark, zorder=3))

    xmin, xmax, ymin, ymax = CSVStats.get_min_max(o1, o2, o3)
    plt.ylim(ymin, ymax)
    plt.xlim(xmin, xmax * 1.2)
    plt.ylabel('Seconds per round')

    plt.legend(loc=u'lower right')
    mplot.plotEnd()
Esempio n. 10
0
def plotScatter():
    mplot.plotPrepareLogLog(0, 0)
    plot_show('scatter')
    plt.ylabel('Bandwidth [bytes]')
    plt.xlabel('Time since start [s]')
    data = read_csvs_xname("time", *sc_scatter)
    styles = ["^"] * 4 + ["s"] * 4
    ranges = []
    for index, label in enumerate(sc_titles):
        if index == 0:
            continue
        plot = data[index]
        y = plot.get_values("bandwidth")
        ranges.append(y)
        plt.scatter(plot.x, y.y, label=label,
                    color=colors[index][1], marker=styles[index])
    plt.legend(loc="upper left")
    xmin, xmax, ymin, ymax = CSVStats.get_min_max(*ranges)
    plt.xlim(0, xmax)
    plt.ylim(0, ymax)
    mplot.plotEnd()
Esempio n. 11
0
def PlotMultiBF(*values_bf):
    mplot.plotPrepareLogLog(2, 0)
    plotbf = []
    pparams = [[color1_light, color1_dark, 'o'],
               [color2_light, color2_dark, 's'],
               [color3_light, color3_dark, '^'],
               [color4_light, color4_dark, '.']]

    for i, value in enumerate(values_bf):
        label = str(int(value.columns['Peers'][0])) + " Peers"
        c1, c2, m = pparams[i]
        plotbf.append( mplot.plotMMA(value, 'round_wall', c1, 0,
                           dict(label=label, linestyle='-', marker=m, color=c2, zorder=3)) )

    xmin, xmax, ymin, ymax = CSVStats.get_min_max(*plotbf)
    plt.ylim(ymin, ymax)
    plt.xlim(xmin, xmax * 1.2)
    plt.ylabel('Seconds per round')
    plt.xlabel('Branching factor')

    plt.legend(loc=u'upper right')
    mplot.plotEnd()
Esempio n. 12
0
def plotAvg(co, jvss, naive, nt):
    mplot.plotPrepareLogLog()

    j_p = jvss.get_values('round_wall')
    plt.plot(j_p.x, j_p.avg, label="JVSS", color=color2_dark, marker='^')

    na_p = naive.get_values('round_wall')
    plt.plot(na_p.x, na_p.avg, label="Naive", color=color3_dark, marker='s')
    #mplot.arrow("      {:.0f} sec".format(na_p.avg[9]), na_p.x[9], 8, color3_dark)

    nt_p = nt.get_values('round_wall')
    plt.plot(nt_p.x, nt_p.avg, label="Ntree", color=color4_dark, marker='v')

    co_p = cothority.get_values('round_wall')
    plt.plot(co_p.x, co_p.avg, label="Cothority", color=color1_dark, marker='o')

    # Make horizontal lines and add arrows for JVSS
    xmin, xmax, ymin, ymax = CSVStats.get_min_max(j_p, na_p, nt_p, co_p)
    plt.ylim(ymin, 8)
    plt.xlim(xmin, 1024 * 1.2)
    plt.ylabel('Seconds per round')

    plt.legend(loc=u'lower right')
    mplot.plotEnd()
Esempio n. 13
0
def plotScatter():
    mplot.plotPrepareLogLog(0, 0)
    plot_show('scatter')
    plt.ylabel('Bandwidth [bytes]')
    plt.xlabel('Time since start [s]')
    data = read_csvs_xname("time", *sc_scatter)
    styles = ["^"] * 4 + ["s"] * 4
    ranges = []
    for index, label in enumerate(sc_titles):
        if index == 0:
            continue
        plot = data[index]
        y = plot.get_values("bandwidth")
        ranges.append(y)
        plt.scatter(plot.x,
                    y.y,
                    label=label,
                    color=colors[index][1],
                    marker=styles[index])
    plt.legend(loc="upper left")
    xmin, xmax, ymin, ymax = CSVStats.get_min_max(*ranges)
    plt.xlim(0, xmax)
    plt.ylim(0, ymax)
    mplot.plotEnd()
Esempio n. 14
0
def args_to_csv(argn):
    stats = []
    for a in sys.argv[2:argn + 2]:
        stats.append(CSVStats(a))
    plot_show(argn)
    return stats
Esempio n. 15
0
from mplot import MPlot
from stats import CSVStats

color1_light = 'lightgreen'
color1_dark = 'green'
color2_light = 'lightblue'
color2_dark = 'blue'
color3_light = 'yellow'
color3_dark = 'brown'
color4_light = 'pink'
color4_dark = 'red'

mplot = MPlot()
mplot.plotPrepareLogLog()

mplot.show_fig = True
jvss = CSVStats('test_naive_multi.csv').get_values('round_wall')
plt.plot(jvss.x,
         jvss.avg,
         label='JVSS',
         linestyle='-',
         marker='^',
         color=color2_dark,
         zorder=3)
mplot.plotFilledLegend(jvss.x,
                       jvss.min,
                       jvss.max,
                       "min-max",
                       color2_light,
                       z=0)
mplot.plotEnd()
Esempio n. 16
0
    for a in sys.argv[2:argn + 2]:
        stats.append(CSVStats(a, xname))
    plot_show(argn)
    return stats


option = sys.argv[1]

if option == "0":
    cothority, jvss, naive, naive_sc, ntree = args_to_csv(5)
    plotAvgMM(cothority, jvss, naive, ntree)
elif option == "1":
    cothority, jvss, naive, naive_sc, ntree = args_to_csv(5)
    CoJVTimeBars(cothority, jvss, naive)
elif option == "2":
    cothority, jvss, naive, naive_sc, ntree = args_to_csv(5)
    CoJVTimeArea(cothority, jvss)
elif option == "3":
    cothority, jvss, naive, naive_sc, ntree = args_to_csv(5)
    SigCheck(naive, naive_sc)
elif option == "4":
    Over(*args_to_csv(3))
elif option == "5":
    PlotMultiBF(*args_to_csv(1, "bf"))
elif option == "6":
    plot_show(1)
    stamp = CSVStats(sys.argv[2], "rate")
    PlotStamp(stamp)
elif option == "7":
    PlotMultiBF(*args_to_csv(4, "bf"))
Esempio n. 17
0
def args_to_csv(argn, xname="Peers"):
    stats = []
    for a in sys.argv[2:argn + 2]:
        stats.append(CSVStats(a, xname))
    plot_show(argn)
    return stats
Esempio n. 18
0
def read_csvs_xname(xname, *values):
    stats = []
    for a in values:
        file = a + '.csv'
        stats.append(CSVStats(file, xname))
    return stats
Esempio n. 19
0
    stats = []
    for a in sys.argv[2:argn + 2]:
        stats.append(CSVStats(a))
    plot_show(argn)
    return stats


option = sys.argv[1]

if option == "0":
    cothority, jvss, naive, naive_sc, ntree = args_to_csv(5)
    plotAvgMM(cothority, jvss, naive, ntree)
elif option == "1":
    cothority, jvss, naive, naive_sc, ntree = args_to_csv(5)
    CoJVTimeBars(cothority, jvss, naive)
elif option == "2":
    cothority, jvss, naive, naive_sc, ntree = args_to_csv(5)
    CoJVTimeArea(cothority, jvss)
elif option == "3":
    cothority, jvss, naive, naive_sc, ntree = args_to_csv(5)
    SigCheck(naive, naive_sc)
elif option == "4":
    Over(*args_to_csv(3))
elif option == "5":
    plot_show(1)
    PlotBF(CSVStats(sys.argv[2], "bf"))
elif option == "6":
    plot_show(1)
    stamp = CSVStats(sys.argv[2], "rate")
    PlotStamp(stamp)
Esempio n. 20
0
color1_dark = 'green'
color2_light = 'lightblue'
color2_dark = 'blue'
color3_light = 'yellow'
color3_dark = 'brown'
color4_light = 'pink'
color4_dark = 'red'
mplot = MPlot()

def plot_save(file):
    mplot.pngname = file
    mplot.show_fig = False

stats = "round_wall"
argn = len(sys.argv)
if argn < 2:
    print "Syntax is:"
    print "plot.py file.csv [stat]"
    print "where stat is one of {round_wall, round_system, round_user}"
    sys.exit(1)

if argn > 2:
    stats = sys.argv[2]

data = CSVStats(sys.argv[1], "hosts")
mplot.plotPrepareLogLog()
na = mplot.plotMMA(data, stats, color1_light, 0,
                    dict(label=sys.argv[1], linestyle='-', marker='s', color=color2_dark, zorder=3))
plt.legend(loc='upper left')
plt.ylabel('Time for verification')
mplot.plotEnd()
Esempio n. 21
0
def plotData(
    data,
    name,
    xlabel="Number of witnesses",
    ylabel="Signing round latency in seconds",
    xticks=[],
    loglog=[2, 2],
    xname="hosts",
    legend_pos="lower right",
    yminu=0,
    ymaxu=0,
    xminu=0,
    xmaxu=0,
    title="",
    read_plots=True,
):
    mplot.plotPrepareLogLog(loglog[0], loglog[1])
    if read_plots:
        plots = read_csvs_xname(xname, *data[0])
    else:
        plots = data[0]

    ranges = []
    data_label = []
    plot_show(name)

    for index, label in enumerate(data[1]):
        data_label.append([plots[index], label])
        ranges.append(
            mplot.plotMMA(
                plots[index],
                "round_wall",
                colors[index][0],
                4,
                dict(label=label, linestyle="-", marker="o", color=colors[index][1], zorder=5),
            )
        )

    # Make horizontal lines and add arrows for JVSS
    xmin, xmax, ymin, ymax = CSVStats.get_min_max(*ranges)
    if yminu != 0:
        ymin = yminu
    if ymaxu != 0:
        ymax = ymaxu
    if xminu != 0:
        xmin = xminu
    if xmaxu != 0:
        xmax = xmaxu
    plt.ylim(ymin, ymax)
    plt.xlim(xmin, xmax)
    plt.xlabel(xlabel)
    plt.ylabel(ylabel)

    plt.legend(loc=legend_pos)
    plt.axes().xaxis.grid(color="gray", linestyle="dashed", zorder=0)
    if len(xticks) > 0:
        ax = plt.axes()
        ax.set_xticks(xticks)
    if title != "":
        plt.title(title)
    mplot.plotEnd()
    return data_label
Esempio n. 22
0
def plotData(data,
             name,
             xlabel="Time since last update",
             ylabel="Bandwidth",
             xticks=[],
             loglog=[0, 0],
             xname="time",
             legend_pos="lower right",
             yname="bandwidth",
             yminu=0,
             ymaxu=0,
             xminu=0,
             xmaxu=0,
             title="",
             read_plots=True,
             restart_x=False):
    mplot.plotPrepareLogLog(loglog[0], loglog[1])
    if read_plots:
        plots = read_csvs_xname(xname, *data[0])
    else:
        plots = data[0]

    ranges = []
    data_label = []
    plot_show(name)
    subx = 0
    if restart_x:
        subx = plots[0].columns[xname][0]

    for index, label in enumerate(data[1]):
        data_label.append([plots[index], label])
        # plots[index].print_short()
        if restart_x:
            print subx
            plots[index].column_add(xname, -subx)
            plots[index].get_values("time")

        ranges.append(
            mplot.plotMMA(
                plots[index], yname, colors[index][0], 4,
                dict(label=label,
                     linestyle='-',
                     marker='.',
                     color=colors[index][1],
                     zorder=5)))

    # Make horizontal lines and add arrows for JVSS
    xmin, xmax, ymin, ymax = CSVStats.get_min_max(*ranges)
    if yminu != 0:
        ymin = yminu
    if ymaxu != 0:
        ymax = ymaxu
    if xminu != 0:
        xmin = xminu
    if xmaxu != 0:
        xmax = xmaxu
    plt.ylim(ymin, ymax)
    plt.xlim(xmin, xmax)
    plt.xlabel(xlabel)
    plt.ylabel(ylabel)

    plt.legend(loc=legend_pos)
    plt.axes().xaxis.grid(color='gray', linestyle='dashed', zorder=0)
    if len(xticks) > 0:
        ax = plt.axes()
        ax.set_xticks(xticks)
    if title != "":
        plt.title(title)
    mplot.plotEnd()
    return data_label