Python Sleep For Memory Consumption Measurement Not Accurate
i have a python script (runner.py) which regularly measures memory consumption of a process. to monitor memory consumption I use a helper class called ProcessTimer.py. processtimer
Solution 1:
time.sleep(.5)
doesn't make sure your loop executes twice per second; it just sleeps half a second. If the rest of the code takes 1 second to execute, each iteration will take .5 + 1 = 1.5 seconds.
If you want to measure in more exact intervals, you will need to measure the time it takes to call ptimer.poll()
and then subtract this from .5 seconds.
But from the data above, it seems that ptimer.poll()
takes a substantial amount of time. You may have to optimize the memory measurement code first to be able to measure as fast as you want.
Post a Comment for "Python Sleep For Memory Consumption Measurement Not Accurate"