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,870 points
29 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,160 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 in Python by Omkar
• 67,380 points
60 views
0 votes
0 answers

how can i measure the elapsed time in python?

can you give an example? READ MORE

May 21 in Python by Waseem
• 4,480 points
17 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,420 points
1,319 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
• 67,380 points
131 views
+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 in Python by Neha
• 330 points

edited Jul 8 by Kalgi 220 views
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,160 points
689 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,160 points
235 views