Analytics service class.
More...
|
def | __init__ (self, **kwargs) |
|
def | fit (self, x, y, model='linear') |
| Fitting function For a linear model: y(x) = slope * x + intersect. More...
|
|
def | slope (self) |
|
def | getFittedData (self, filename, x_name='Time', y_name='pss', precision=2, tails=False, minPoints=5) |
|
def | extractFromTable (self, table, x_name, y_name) |
|
def | formatBytes (self, size) |
|
Analytics service class.
Definition at line 1252 of file trfUtils.py.
◆ __init__()
def python.trfUtils.analytic.__init__ |
( |
|
self, |
|
|
** |
kwargs |
|
) |
| |
◆ extractFromTable()
def python.trfUtils.analytic.extractFromTable |
( |
|
self, |
|
|
|
table, |
|
|
|
x_name, |
|
|
|
y_name |
|
) |
| |
Definition at line 1335 of file trfUtils.py.
1335 def extractFromTable(self, table, x_name, y_name):
1336 headerUpperVersion = {
'pss':
'PSS',
'swap':
'Swap',
'rss':
'RSS',
'vmem':
'VMEM'}
1337 x = table.get(x_name, [])
1338 if '+' not in y_name:
1339 y = table.get(y_name, [])
1341 y = table.get(headerUpperVersion[y_name], [])
1344 y1_name = y_name.split(
'+')[0]
1345 y2_name = y_name.split(
'+')[1]
1346 y1_value = table.get(y1_name, [])
1347 y2_value = table.get(y2_name, [])
1348 if len(y1_value)==0
or len(y2_value)==0:
1349 y1_value = table.get(headerUpperVersion[y1_name], [])
1350 y2_value = table.get(headerUpperVersion[y2_name], [])
1351 except Exception
as e:
1352 msg.warning(
'exception caught: {0}'.
format(e))
1357 y = [x0 + y0
for x0, y0
in zip(y1_value, y2_value)]
◆ fit()
def python.trfUtils.analytic.fit |
( |
|
self, |
|
|
|
x, |
|
|
|
y, |
|
|
|
model = 'linear' |
|
) |
| |
Fitting function For a linear model: y(x) = slope * x + intersect.
- Parameters
-
x | list of input data (list of floats or ints). |
y | list of input data (list of floats or ints). |
model | model name (string). |
Definition at line 1264 of file trfUtils.py.
1264 def fit(self, x, y, model='linear'):
1266 self._fit = Fit(x=x, y=y, model=model)
1267 except Exception
as e:
1268 msg.warning(
'fit failed! {0}'.
format(e))
◆ formatBytes()
def python.trfUtils.analytic.formatBytes |
( |
|
self, |
|
|
|
size |
|
) |
| |
Definition at line 1363 of file trfUtils.py.
1363 def formatBytes(self, size):
1367 power_labels = {1:
'K', 2:
'M', 3:
'G', 4:
'T'}
1371 return round(size, 2), power_labels[n]+
'B/s'
◆ getFittedData()
def python.trfUtils.analytic.getFittedData |
( |
|
self, |
|
|
|
filename, |
|
|
|
x_name = 'Time' , |
|
|
|
y_name = 'pss' , |
|
|
|
precision = 2 , |
|
|
|
tails = False , |
|
|
|
minPoints = 5 |
|
) |
| |
Definition at line 1292 of file trfUtils.py.
1292 def getFittedData(self, filename, x_name='Time', y_name='pss', precision=2, tails=False, minPoints=5):
1293 _memFileToTable = memFileToTable()
1295 table = _memFileToTable.getTable(filename, header=
None, separator=
"\t")
1298 x, y = self.extractFromTable(table, x_name, y_name)
1304 tail =
int(len(x)/5)
1305 msg.info(
'removing tails from the memory monitor data; 20% from each side')
1311 if len(x)==len(y)
and len(x) > minPoints:
1312 msg.info(
'fitting {0} vs {1}'.
format(y_name, x_name))
1314 fit = self.fit(x, y)
1315 _slope = self.slope()
1316 except Exception
as e:
1317 msg.warning(
'failed to fit data, x={0}, y={1}: {2}'.
format(x, y, e))
1320 slope =
round(fit.slope(), precision)
1321 chi2 =
round(fit.chi2(), precision)
1322 fitResult = {
"slope": slope,
"chi2": chi2}
1324 HRslope, unit = self.formatBytes(slope)
1325 msg.info(
'slope of the fitted line: {0} {1} (using {2} data points, chi2={3})'.
format(HRslope, unit, len(x), chi2))
1327 msg.warning(
'wrong length of table data, x={0}, y={1} (must be same and length>={2})'.
format(x, y, minPoints))
◆ slope()
def python.trfUtils.analytic.slope |
( |
|
self | ) |
|
Definition at line 1273 of file trfUtils.py.
1277 slope = self._fit.slope()
1279 msg.warning(
'Fit has not been defined')
◆ _fit
python.trfUtils.analytic._fit |
|
staticprivate |
The documentation for this class was generated from the following file: