Answers for "python timing execution"

6

python time execution

import time
start_time = time.time()
print("Hello") 	# Hello
end_time = time.time()
total_time = end_time - start_time
print("Time: ", total_time)
Posted by: Guest on February-16-2021
0

python timing code

1# latest_tutorial.py
 2
 3import time
 4from reader import feed
 5
 6def main():
 7    """Print the latest tutorial from Real Python"""
 8    tic = time.perf_counter()
 9    tutorial = feed.get_article(0)
10    toc = time.perf_counter()
11    print(f"Downloaded the tutorial in {toc - tic:0.4f} seconds")
12
13    print(tutorial)
14
15if __name__ == "__main__":
16    main()
Posted by: Guest on July-07-2021

Python Answers by Framework

Browse Popular Code Answers by Language