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,890 points
64 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,230 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,000 points
121 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,530 points
66 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
2,064 views
+4 votes
6 answers

Use of "continue" in python

The break statement is used to "break" ...READ MORE

answered Jul 16, 2018 in Python by Omkar
• 69,000 points
165 views
0 votes
1 answer
+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 6, 2019 in Python by Neha
• 330 points

edited Jul 8, 2019 by Kalgi 777 views
0 votes
0 answers
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,230 points
3,111 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,230 points
570 views