From bdd03a963574de5e09efefbf56862d8a7380f30f Mon Sep 17 00:00:00 2001 From: DJh2o2 Date: Mon, 8 Aug 2022 17:30:30 +0200 Subject: [PATCH] add avgs --- bandwidth.py | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/bandwidth.py b/bandwidth.py index 971c614..924d7ab 100644 --- a/bandwidth.py +++ b/bandwidth.py @@ -1,6 +1,6 @@ import matplotlib.pyplot as plt import mysql.connector -#matplotlib.use('tkAgg') +# matplotlib.use('tkAgg') # mariadb mariadbConnection = mysql.connector.connect( @@ -13,6 +13,7 @@ times = [] pings = [] downloads = [] uploads = [] +sum_ping = 0.0 for i in mariadbResult: times.append(i[0]) @@ -20,6 +21,17 @@ for i in mariadbResult: downloads.append(i[2]) uploads.append(i[3]) +# Python program to get average of a list + + +def Average(lst): + return sum(lst) / len(lst) + + +print("avg ping = ", Average(pings), " ms") +print("avg download = ", Average(downloads) / 1000000, " mbit/s") +print("avg upload = ", Average(uploads) / 1000000, " mbit/s") + # plot plt.plot(times, pings, label="Ping") plt.plot(times, downloads, label="Download")