master
DJh2o2 2022-08-08 17:30:30 +07:00
parent 0f71db2b85
commit bdd03a9635
1 changed files with 13 additions and 1 deletions

@ -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")