4/18/2016 - 10:04 AM

spend time run

Calculate how many time spend any code to run

from datetime import datetime
import os

""" in first line of body script """

# current time
tic =

""" in last line of body script """

# calculate time of processing
toc =
tictoc = ((toc-tic).seconds)/60. # minutes
print ("\nProcess start: %s"%tic)
print ("Process finish: %s"%toc)
print ("Process time spent %s minutes"%tictoc)
# notification 
os.system('notify-send "THE END" "The process was over!!!\nIt spent %s minutes.\nHAVE A GOOD DAY..."'%tictoc)

print ("\n--- The End ---")