Skip to content

Instantly share code, notes, and snippets.

@diegolovison
Created May 20, 2020 19:37
Show Gist options
  • Save diegolovison/8a6ea145a85305694a16b847ff46b068 to your computer and use it in GitHub Desktop.
Save diegolovison/8a6ea145a85305694a16b847ff46b068 to your computer and use it in GitHub Desktop.
Scalability Tests Prediction from RadarGun Benchmark
import pandas as pd
from datetime import datetime
import numpy as np
# https://github.com/wip727/PyUSL/issues/1
from usl_v2 import usl_v2
def _append(node, max_index, row):
sum_value = 0
l = reversed(range(max_index + 1))
for i in l:
key = 'Slave ' + str(i)
sum_value += row[key]
master_key = 'Slave ' + str(max_index)
if master_key not in node:
node[master_key] = []
node[master_key].append(sum_value)
nodes = range(8)
usecols = []
usecols.append('Timestamp')
for n in nodes:
usecols.append('Slave ' + str(n))
data = pd.read_csv('/Users/dlovison/Downloads/timeline_asyncRepl_default_8_BasicOperations.Put_Throughput.csv',
usecols=usecols)
# convert Java timestamp to Python datetime
data['Timestamp'] = data['Timestamp'].apply(lambda x: datetime.fromtimestamp(x / 1000))
data.set_index('Timestamp', inplace=True)
data.fillna(0, inplace=True)
# lets sum every seconds
data_resample = data.resample('1s').sum()
node_dic = {}
for index, row in data_resample.iterrows():
for n in nodes:
if row['Slave ' + str(n)] != 0 and \
('Slave ' + str(n + 1) not in data_resample or row['Slave ' + str(n + 1)] == 0):
_append(node_dic, n, row)
break
y = []
x = []
for n in nodes:
y.append(np.mean(node_dic['Slave ' + str(n)]))
x.append(n + 1)
u = usl_v2()
# show current status
u.fit(x, y)
# predict 1 to 20 nodes
xgrid = np.linspace(1, 20, 200)
# show the prediction
u.plot(xgrid)
# I did a check with > peak.scalability(usl.dg) using R language and usl library
# source
# https://cran.r-project.org/web/packages/usl/vignettes/usl.pdf
# http://www.easysurf.cc/scintd.htm
# https://github.com/wip727/PyUSL
# http://www.perfdynamics.com/Manifesto/USLscalability.html#tth_sEc2.4
# https://www.vividcortex.com/resources/universal-scalability-law/
# https://www.vividcortex.com/resources/queueing-theory
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment