Skip to content

Instantly share code, notes, and snippets.

@cdoan1
Created June 21, 2021 20:30
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cdoan1/da065bab9fb1abc5ac19bcf80845bc16 to your computer and use it in GitHub Desktop.
Save cdoan1/da065bab9fb1abc5ac19bcf80845bc16 to your computer and use it in GitHub Desktop.
rate calculation
def delta_sn(a, b):
d1 = datetime.strptime(a, '%Y-%m-%dT%H:%M:%SZ')
d2 = datetime.strptime(b, '%Y-%m-%dT%H:%M:%SZ')
diff = (d2 - d1).total_seconds() / 60
return round(diff, 1)
def calculate_rate(attribute_name):
a0 = ds8[(ds8[attribute_name] > 0)]
a0_max = ds8[(ds8[attribute_name] == ds8[attribute_name].max())]
a01 = a0.reset_index(drop=True)
a02 = a0_max.reset_index(drop=True)
print('{:<12s}{:>12s}{:>20s}{:>1s}'.format(attribute_name,'duration (h)',':', str( round(delta_sn(a01['date'][0], a02['date'][0]) / 60,1)) ))
print('{:<12s}{:>12s}{:>13s}{:>1s}'.format(attribute_name,'rate clusters/hours',':', str( round(a02[attribute_name][0] / (delta_sn(a01['date'][0], a02['date'][0]) / 60),1)) ))
# print(attribute_name + ' duratiom (h) :' + )
# print(attribute_name + ' rate clusters/hours :' + str( round(a02[attribute_name][0] / (delta_sn(a01['date'][0], a02['date'][0]) / 60),1) ))
run_date='6/21/2021'
title='1K Provision, WAN Emulation On, RHACM 2.3/AI, Bare Metal/virtual Bare Metal' + ', ' + run_date
l={
"value" : "# clusters",
"date" : ""
}
fig = px.line(ds8,
x='date',
y=['initialized',
'iso_gen',
'iso_bmh',
'booted',
'discovered',
'provisioning',
'install_failed',
'completed',
'managed',
# 'agents_available'
],
labels=l)
fig.add_trace(go.Scatter(x=ds8['date'], y=ds8['initialized'] - ds8['completed'] - ds8['install_failed'], name='concurrency',
line=dict(color='black', width=2, dash='dash')))
# calculate average concurrency, manually bound the data set
# calculating the concurrecy without bound does not give meaningful results
cc = ds8[(ds8['date'] > '2021-06-19T02:00:00Z') & (ds8['date'] < '2021-06-19T04:00:00Z')]
cc_mean = np.mean(cc['initialized'] - cc['completed'] - cc['install_failed'])
cc_max = np.max(cc['initialized'] - cc['completed'] - cc['install_failed'])
print('approx concurrency mean :' + str( round(cc_mean,1) ))
print('approx concurrency max :' + str( round(cc_max,1) ))
calculate_rate('initialized')
calculate_rate('completed')
calculate_rate('managed')
fig.update_layout(
title=title,
legend_orientation='v'
)
fig.show()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment