import matplotlib.pyplot as plt

plt.rcParams.update({'font.size':35})

def single_listener():
    fig, (ax1,ax2) = plt.subplots(1,2)

    x = [1,10,100,1000]

    y11 = [0.00068,0.0047,0.045,00.63]
    y12 = [0.00530,2.1000,7.200,17.00]
    y13 = [0.00210,0.1800,0.860,05.60]

    ax1.plot(x, y12, label="Maximum", linewidth=5)
    ax1.plot(x, y13, label="Average", linewidth=5)
    ax1.plot(x, y11, label="Minimum", linewidth=5)

    ax1.legend(bbox_to_anchor=(0.2,1.4))
    ax1.grid(linewidth=2)
    ax1.set_title("Laptop")

    ax1.set_xlabel("Event count")
    ax1.set_ylabel("Time")

    ax1.set_xscale("log")
    ax1.set_yscale("log")

    ###

    y21 = [0.0004,0.003,0.025,00.24]
    y22 = [0.0022,1.000,2.200,16.00]
    y23 = [0.0016,0.056,0.440,05.20]

    ax2.plot(x, y22, label="Maximum", linewidth=5)
    ax2.plot(x, y23, label="Average", linewidth=5)
    ax2.plot(x, y21, label="Minimum", linewidth=5)

    ax2.grid(linewidth=2)
    ax2.set_title("Desktop")

    ax2.set_xlabel("Event count")
    ax2.set_ylabel("Time")

    ax2.set_xscale("log")
    ax2.set_yscale("log")

    fig.set_figheight(12)
    fig.set_figwidth(35)
    fig.set_dpi(100)

    fig.savefig("performance_results/single_listener.png",bbox_inches='tight')

def multiple_listeners():
    fig, (ax1,ax2) = plt.subplots(1,2)

    x = [1,10,100,250,500,1000]

    y11 = [00.63,00.46,00.42,0.51,0.59,00.92]
    y12 = [17.00,25.00,20.00,7.90,1.60,03.24]
    y13 = [05.60,07.60,07.10,2.90,0.72,01.49]

    ax1.plot(x, y12, label="Maximum", linewidth=5)
    ax1.plot(x, y13, label="Average", linewidth=5)
    ax1.plot(x, y11, label="Minimum", linewidth=5)

    ax1.legend(bbox_to_anchor=(0.2,1.4))
    ax1.grid(linewidth=2)
    ax1.set_title("Laptop")

    ax1.set_xlabel("Listener count")
    ax1.set_ylabel("Time")

    ax1.set_xscale("log")
    ax1.set_yscale("log")

    ###

    y21 = [00.24,00.24,00.25,00.27,0.31,0.38]
    y22 = [16.00,19.00,10.00,12.00,0.33,0.42]
    y23 = [05.20,04.00,01.00,00.90,0.31,0.4]

    ax2.plot(x, y22, label="Maximum", linewidth=5)
    ax2.plot(x, y23, label="Average", linewidth=5)
    ax2.plot(x, y21, label="Minimum", linewidth=5)

    ax2.grid(linewidth=2)
    ax2.set_title("Desktop")

    ax2.set_xlabel("Listener count")
    ax2.set_ylabel("Time")

    ax2.set_xscale("log")
    ax2.set_yscale("log")

    fig.set_figheight(12)
    fig.set_figwidth(35)
    fig.set_dpi(100)

    fig.savefig("performance_results/multiple_listeners.png",bbox_inches='tight')

def multiple_monitors():
    fig, (ax1,ax2) = plt.subplots(1,2)

    x = [1,10,100,250,500,1000]

    y11 = [00.63,00.45,00.38,00.40,0.44,0.52]
    y12 = [17.00,25.00,18.00,13.00,2.90,2.30]
    y13 = [05.60,06.60,04.40,01.80,0.72,0.70]

    ax1.plot(x, y12, label="Maximum", linewidth=5)
    ax1.plot(x, y13, label="Average", linewidth=5)
    ax1.plot(x, y11, label="Minimum", linewidth=5)

    ax1.legend(bbox_to_anchor=(0.2,1.4))
    ax1.grid(linewidth=2)
    ax1.set_title("Laptop")

    ax1.set_xlabel("Monitor count")
    ax1.set_ylabel("Time")

    ax1.set_xscale("log")
    ax1.set_yscale("log")

    ###

    y21 = [00.24,00.23,00.24,0.25,0.26,0.29]
    y22 = [16.00,20.00,18.00,7.60,0.30,0.30]
    y23 = [05.20,06.50,02.90,0.80,0.27,0.29]

    ax2.plot(x, y22, label="Maximum", linewidth=5)
    ax2.plot(x, y23, label="Average", linewidth=5)
    ax2.plot(x, y21, label="Minimum", linewidth=5)

    ax2.grid(linewidth=2)
    ax2.set_title("Desktop")

    ax2.set_xlabel("Monitor count")
    ax2.set_ylabel("Time")

    ax2.set_xscale("log")
    ax2.set_yscale("log")

    fig.set_figheight(12)
    fig.set_figwidth(35)
    fig.set_dpi(100)

    fig.savefig("performance_results/multiple_monitors.png",bbox_inches='tight')

if __name__ == "__main__":
    single_listener()
    multiple_listeners()
    multiple_monitors()
