I create a while loop and print the timestamp on every loop. At the beginning I got a performance of about 33 loops by second. However, longer it takes, slower it gets. At 3 minutes, I have a performance of 2 loops by second. I tried to use threading.Timer instead, but it does the same thing. I am aware that Memory and Complexity of calculations can be an issue, but it doesn't seem to be the case in that scenario.
How can I avoid that lack of performance as I want to run the code for hours? Your help would be really appreciated.
import time
while(True):
print(int(round(time.time() * 1000)))
Output
1556756682157
1556756682216
1556756682240
1556756682269
1556756682296
1556756682324
1556756682358
1556756682387
1556756682415
1556756682441
1556756682470
1556756682501
1556756682556
... // After 3 minutes
1556756860002
1556756860884
1556756861240
1556756861669
1556756862596
1556756863324
1556756863858
1556756864387
printcan considerably slow down too. So I will try to get rid of it and test it.