Daily Dose of Data Science

Share this post

Don't Use time.time() To Measure Execution Time

www.blog.dailydoseofds.com

Don't Use time.time() To Measure Execution Time

Avi Chawla
Nov 5, 2022
2
Share
Share this post

Don't Use time.time() To Measure Execution Time

www.blog.dailydoseofds.com

The π˜π—Άπ—Ίπ—²() method from the time library is frequently used to measure the execution time.

However, π˜π—Άπ—Ίπ—²() is not meant for timing your code. Rather, its actual purpose is to tell the current time. This, at many times, compromises the accuracy of measuring the exact run time.

The correct approach is to use 𝗽𝗲𝗿𝗳_π—°π—Όπ˜‚π—»π˜π—²π—Ώ(), which deals with relative time. Thus, it is considered the most accurate way to time your code.

Thanks for reading Daily Dose of Data Science! Subscribe for free to learn something new and insightful about Python and Data Science every day. Also, get a Free Data Science PDF (250+ pages) with 200+ tips.


I like to explore, experiment and write about data science concepts and tools. You could connect with me on LinkedIn.

2
Share
Share this post

Don't Use time.time() To Measure Execution Time

www.blog.dailydoseofds.com
Previous
Next
Comments
Top
New
Community

No posts

Ready for more?

Β© 2023 Avi Chawla
Privacy βˆ™ Terms βˆ™ Collection notice
Start WritingGet the app
SubstackΒ is the home for great writing