Simplify intervals skips and fix throughput computation per second

Don't use Excel dates, do all the tests in python datetime class
Aslo, we need to divide by the actual duration of the interval to
get a viable throughput per second for when some data are missing
This commit is contained in:
Matthieu Herrb 2023-02-18 20:20:23 +01:00
parent 54e5538695
commit 32a1cd3cbc

View file

@ -10,13 +10,8 @@ import gzip
import lzma
def to_date(s):
dt=datetime.datetime.strptime(s,"%a %b %d %H:%M:%S %Z %Y")-datetime.datetime(1899,12,30)
return dt.days+(dt.seconds+dt.microseconds*1.0e-6)/86400.0
def to_datetime(xd):
return datetime.datetime(1900,1,1)+datetime.timedelta(xd)
dt=datetime.datetime.strptime(s,"%a %b %d %H:%M:%S %Z %Y")
return dt
b_or_p=sys.argv[1] # "b" or "p"
@ -74,21 +69,19 @@ for t in t_l:
iface_d[i]=None
iface_l=iface_d.keys()
#iface_l.sort()
#print(iface_l)
#print "T,",",".join(iface_l)
prev={}
for i in iface_l:
prev[i]=None
t0=t_l[0]
tn0=0
for i in iface_l:
prev[i]=d[t0][i][b_or_p][txrx]
tn0=t_l[0]
mb_l=[]
for t in t_l:
tn=int(86400.0*(t-t0)/300.0)
if tn<=tn0 and t!=t0: continue
tn0=tn
s="%f"%t
# print(t, " ", tn0, " ", tn0 + datetime.timedelta(minutes=5))
if (t < tn0 + datetime.timedelta(minutes=5)): continue
delta = (t - tn0).seconds
# if (delta > 450): print("xxxx ", tn0, " ", t, " ", delta)
tn0=t
tot_mbit_s = 0.0;
for i in iface_l:
y=0
@ -98,14 +91,12 @@ for t in t_l:
if prev[i]!=None and x!=None:
y=x-prev[i]
if y<0.0: y=0
s+=",%d"%y
mbit_s=float(y)*8.0/300.0e6
#if mbit_s>600.0: print to_datetime(t),mbit_s
mbit_s=float(y)*8.0/(delta*1e6)
# if mbit_s>600.0: print(i, " ", t, " ", mbit_s)
if mbit_s>10000.0: mbit_s=0.0
tot_mbit_s += mbit_s;
prev[i]=x
prev[i]=x
mb_l.append(tot_mbit_s)
#print(s)
mb_l.sort()
mb_n=len(mb_l)