From 842ee7ec0470d0ea1ba97415497c64d506793f0e Mon Sep 17 00:00:00 2001 From: Bob Mottram Date: Tue, 19 Oct 2021 19:08:18 +0100 Subject: [PATCH] Change fitness metrics structure --- fitnessFunctions.py | 27 ++++++++++++++------------- 1 file changed, 14 insertions(+), 13 deletions(-) diff --git a/fitnessFunctions.py b/fitnessFunctions.py index 43028b135..9feb14491 100644 --- a/fitnessFunctions.py +++ b/fitnessFunctions.py @@ -19,25 +19,26 @@ def fitnessPerformance(startTime, fitnessState: {}, fitnessState['performance'] = {} if fitnessId not in fitnessState['performance']: fitnessState['performance'][fitnessId] = {} + if watchPoint not in fitnessState['performance'][fitnessId]: + fitnessState['performance'][fitnessId][watchPoint] = { + "total": 0, + "ctr": 0 + } timeDiff = time.time() - startTime - fitnessState['performance'][fitnessId][watchPoint] = timeDiff - if 'total' in fitnessState['performance'][fitnessId]: - fitnessState['performance'][fitnessId]['total'] += timeDiff - fitnessState['performance'][fitnessId]['ctr'] += 1 - if fitnessState['performance'][fitnessId]['ctr'] >= 1024: - fitnessState['performance'][fitnessId]['total'] /= 2 - fitnessState['performance'][fitnessId]['ctr'] = \ - int(fitnessState['performance'][fitnessId]['ctr'] / 2) - else: - fitnessState['performance'][fitnessId]['total'] = timeDiff - fitnessState['performance'][fitnessId]['ctr'] = 1 + fitnessState['performance'][fitnessId][watchPoint]['total'] += timeDiff + fitnessState['performance'][fitnessId][watchPoint]['ctr'] += 1 + if fitnessState['performance'][fitnessId][watchPoint]['ctr'] >= 1024: + fitnessState['performance'][fitnessId][watchPoint]['total'] /= 2 + fitnessState['performance'][fitnessId][watchPoint]['ctr'] = \ + int(fitnessState['performance'][fitnessId][watchPoint]['ctr'] / 2) if debug: + ctr = fitnessState['performance'][fitnessId][watchPoint]['ctr'] + total = fitnessState['performance'][fitnessId][watchPoint]['total'] print('FITNESS: performance/' + fitnessId + '/' + - watchPoint + '/' + - str(fitnessState['performance'][fitnessId][watchPoint])) + watchPoint + '/' + str(total * 1000 / ctr)) def fitnessThread(baseDir: str, fitness: {}):