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

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()
end = time.time()
print(end - start)

This gives the execution time in seconds.
answered Dec 5, 2018 by SDeb
• 13,290 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,150 points
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
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, To ...READ MORE

answered Apr 28, 2020 in Python by Gitika
• 65,950 points
+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
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 6, 2019 in Python by Neha
• 330 points

edited Jul 8, 2019 by Kalgi 2,352 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,290 points
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,290 points