Measurement of time elapsed

0 votes
If I want to start counting time somewhere in my code and then get the passed time in order to measure the time it took to execute few function what should i do? I have used the timeit module but is this the right way?

import timeit

start = timeit.timeit()
print "hello"
end = timeit.timeit()
print end - start
Dec 5, 2018 in Python by ana1504.k
• 7,910 points
668 views

1 answer to this question.

0 votes
If you just want to measure the elapsed wall-clock time between two points, you could use time.time():

import time

start = time.time()
print("hello")
end = time.time()
print(end - start)
 

This gives the execution time in seconds.
answered Dec 5, 2018 by SDeb
• 13,300 points

Related Questions In Python

0 votes
1 answer

How to check latest change time of each file using glob in python?

You can get the changing time from ...READ MORE

answered Jan 2, 2019 in Python by Omkar
• 69,220 points
1,547 views
0 votes
0 answers

how can i measure the elapsed time in python?

can you give an example? READ MORE

May 21, 2019 in Python by Waseem
• 4,540 points
631 views
0 votes
1 answer

how to run test cases of different modules with same marker at a time using pytest

Hey,@Nikitha, Suppose you have multiple files say test_sample1.py, test_sample2.py. To ...READ MORE

answered Apr 28, 2020 in Python by Gitika
• 65,770 points
1,775 views
+2 votes
3 answers

what is the practical use of polymorphism in Python?

Polymorphism is the ability to present the ...READ MORE

answered Mar 31, 2018 in Python by anto.trigg4
• 3,440 points
4,859 views
0 votes
2 answers
+1 vote
2 answers

how can i count the items in a list?

Syntax :            list. count(value) Code: colors = ['red', 'green', ...READ MORE

answered Jul 7, 2019 in Python by Neha
• 330 points

edited Jul 8, 2019 by Kalgi 4,421 views
0 votes
1 answer
0 votes
1 answer

How to measure time elapsed in Python?

If you just want to measure the ...READ MORE

answered Dec 4, 2018 in Python by SDeb
• 13,300 points
12,423 views
0 votes
1 answer

Indentation of Python in Notepad++

To indent the block, select the entire ...READ MORE

answered Sep 18, 2018 in Python by SDeb
• 13,300 points
2,341 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP