How to use time.clock() function in python

Gabriel Genellina gagsl-py at yahoo.com.ar
Mon Jan 22 23:34:20 CET 2007


At Monday 22/1/2007 19:05, yinglcs at gmail.com wrote:

>I am following this python example trying to time how long does an
>operation takes, like this:
>
>My question is why the content of the file (dataFile) is just '0.0'?
>I have tried "print >>dataFile, timeTaken" or "print >>dataFile,str(
>timeTaken)", but gives me 0.0.
>Please tell me what am I missing?
>
>
>         t1 = time.clock()
>         os.system(cmd)
>
>         outputFile = str(i) + ".png"
>
>         t2 = time.clock()
>
>         timeTaken = t2 - t1
>         allTimeTaken += timeTaken
>         print >>dataFile, timeTaken

time.clock() may not give you enough precision; see this recent post
http://mail.python.org/pipermail/python-list/2007-January/422676.html
Use the timeit module instead.


-- 
Gabriel Genellina
Softlab SRL 


	

	
		
__________________________________________________ 
Preguntá. Respondé. Descubrí. 
Todo lo que querías saber, y lo que ni imaginabas, 
está en Yahoo! Respuestas (Beta). 
¡Probalo ya! 
http://www.yahoo.com.ar/respuestas 




More information about the Python-list mailing list