Measure Execution Time of Code in Seconds using Python

time.time function

import time def doSomething(seconds): time.sleep(seconds) startTime = time.time() doSomething(3) endTime = time.time() executionTime = endTime - startTime print('%.8f sec' % executionTime)

Leave a Comment

Cancel reply

Your email address will not be published.