Sample Header Ad - 728x90

Facing problem to test Energy Consumption by a factorial function with Python module "pyRAPL"

0 votes
1 answer
316 views
I would like to calculate energy consumption. That's why I have used the following program, unfortunately it gave errors. **MWE:** #need python3.7 to run this from math import * import time # time module is used to delay your program for a bit so that you can get a reading, that is not zero #but delay will/might give you more noise from the system import pyRAPL a=1 pyRAPL.setup() measure= pyRAPL.Measurement('bar') measure.begin() #to begin a measurement for i in range (100): a=a*(i+1) print (a) time.sleep(0.001) #this time delay (in seconds) is the approximate minimum time of which it gives a reading, any duration lesser #than this might yield '0' energy consumption measure.end() #to end the measurement val =measure.result #output the result by the following print (val) #the above result will contain 5 values #access one by one with the following syntax print ('label= ',val.label) print ('timestamp= ', val.timestamp) #it gives the exact time of initialisation of measurement, (in epoch) needs to be converted to date and time format print ('duration= ', val.duration) #gives the duration of program running between begin() and end() print ('energy consumed by CPU= ', val.pkg) #value of energy consumption by the CPU in micro Joules <==== We need this print ('dram value = ',val.dram) #value of RAM energy consumption (in seconds) <--- needs to be converted, not so sure how **Errors result:** enter image description here How can I fix this problem?
Asked by BSFU (13 rep)
Jun 8, 2020, 02:52 AM
Last activity: Nov 6, 2020, 07:04 AM