Change fitness metrics structure

merge-requests/30/head
Bob Mottram 2021-10-19 19:08:18 +01:00
parent 2bd1bef5b4
commit 842ee7ec04
1 changed files with 14 additions and 13 deletions

View File

@ -19,25 +19,26 @@ def fitnessPerformance(startTime, fitnessState: {},
fitnessState['performance'] = {} fitnessState['performance'] = {}
if fitnessId not in fitnessState['performance']: if fitnessId not in fitnessState['performance']:
fitnessState['performance'][fitnessId] = {} fitnessState['performance'][fitnessId] = {}
if watchPoint not in fitnessState['performance'][fitnessId]:
fitnessState['performance'][fitnessId][watchPoint] = {
"total": 0,
"ctr": 0
}
timeDiff = time.time() - startTime timeDiff = time.time() - startTime
fitnessState['performance'][fitnessId][watchPoint] = timeDiff fitnessState['performance'][fitnessId][watchPoint]['total'] += timeDiff
if 'total' in fitnessState['performance'][fitnessId]: fitnessState['performance'][fitnessId][watchPoint]['ctr'] += 1
fitnessState['performance'][fitnessId]['total'] += timeDiff if fitnessState['performance'][fitnessId][watchPoint]['ctr'] >= 1024:
fitnessState['performance'][fitnessId]['ctr'] += 1 fitnessState['performance'][fitnessId][watchPoint]['total'] /= 2
if fitnessState['performance'][fitnessId]['ctr'] >= 1024: fitnessState['performance'][fitnessId][watchPoint]['ctr'] = \
fitnessState['performance'][fitnessId]['total'] /= 2 int(fitnessState['performance'][fitnessId][watchPoint]['ctr'] / 2)
fitnessState['performance'][fitnessId]['ctr'] = \
int(fitnessState['performance'][fitnessId]['ctr'] / 2)
else:
fitnessState['performance'][fitnessId]['total'] = timeDiff
fitnessState['performance'][fitnessId]['ctr'] = 1
if debug: if debug:
ctr = fitnessState['performance'][fitnessId][watchPoint]['ctr']
total = fitnessState['performance'][fitnessId][watchPoint]['total']
print('FITNESS: performance/' + fitnessId + '/' + print('FITNESS: performance/' + fitnessId + '/' +
watchPoint + '/' + watchPoint + '/' + str(total * 1000 / ctr))
str(fitnessState['performance'][fitnessId][watchPoint]))
def fitnessThread(baseDir: str, fitness: {}): def fitnessThread(baseDir: str, fitness: {}):