diff options
Diffstat (limited to 'compute_aep_calib.py')
-rwxr-xr-x | compute_aep_calib.py | 97 |
1 files changed, 97 insertions, 0 deletions
diff --git a/compute_aep_calib.py b/compute_aep_calib.py new file mode 100755 index 0000000..15891a1 --- /dev/null +++ b/compute_aep_calib.py @@ -0,0 +1,97 @@ +#!/usr/bin/env python + +import os +import sys +import getopt +import subprocess +import signal +import serial +import time +import math + +def delta_nrj(delta, myline, min=[0,0,0,0,0], max=[0,0,0,0,0]): + array = myline.split(" ") + + if (delta[0] < 0): + delta[0] = int(array[0]) + + time = int(array[0]) - delta[0] + if (time <= 0): + return delta + +# print array + for i in range(0, len(array)): + try: + data = int(array[i]) + except ValueError: + continue + + if (data < min[i]): + min[i] = data + if (data > max[i]): + max[i] = data + delta[i] += time * data + + delta[0] = int(array[0]) + +# print delta + return delta + +def compute_aep(infile, dry_run=True, verbose=False): + skip = 1 + try: + fi = open(infile, "r") + except IOError: + print "WARN: Unable to open %s" % (infile) + sys.exit(2) + + lines = fi.readlines() + + offset = [0, 0, 0, 0, 0] + nrj = [-1, -0, -0, -0, -0] + max = [0, 0, 0, 0, 0] + min = [50000000, 5000000, 5000000, 5000000, 5000000] + label = ["time", "A53 core ", "A53 cache", "A57 core ", "A57 cache"] + + for myline in lines: + if skip: + skip = 0 + continue + delta_nrj(nrj, myline, min, max) + + total = 0 + for i in range(1, len(nrj)): + nrj[i] -= offset[i] * nrj[i] + total += nrj[i] + print "Total nrj: %8.3f J for %s -- duration %8.3f sec -- min %8.3f W -- max %8.3f W" % (nrj[i]/1000000000000.0, label[i], (max[0]-min[0])/1000000.0, min[i]/1000000.0, max[i]/1000000.0) + if (min[i] < offset[i]): + print "!!! Min below offset" + + print "Total nrj: %8.3f J for %s -- duration %8.3f sec" % (total/1000000000000.0, "Platform ", (max[0]-min[0])/1000000.0) + + +if __name__ == '__main__': + + def handleSigTERM(signum, frame): + record = False + + signal.signal(signal.SIGTERM, handleSigTERM) + signal.signal(signal.SIGINT, handleSigTERM) + + infile = "EC-pmu.txt" + verbose = False + + try: + opts, args = getopt.getopt(sys.argv[1:], "i:v") + except getopt.GetoptError as err: + print str(err) # will print something like "option -a not recognized" + sys.exit(2) + + for o, a in opts: + if o == "-i": + infile = a + if o == "-v": + verbose = True + + compute_aep(infile, False, verbose) + |