Wednesday, October 3, 2018

Timing code in Python

To time a particular code block in Python, do this:

import time

t = time.time()
#<code_block>
print(f'code-block-name:{time.time()-t})

[Courtesy: this]




No comments:

Post a Comment