Re: [Tutor] time taken to execute certain task

2011-03-17 Thread Steven D'Aprano
tee chwee liong wrote: hi, i would like to know the time taken to execute a certain task in python. i used time.time and time.clock and i see the time taken is different? what is the right method to use? Neither, or either. For timing small code snippets, the right tool is the timeit module

Re: [Tutor] time taken to execute certain task

2011-03-17 Thread ALAN GAULD
u are effectively profiling a single if statement... Alan Gauld Author of the Learn To Program website http://www.alan-g.me.uk/ From: tee chwee liong To: alan.ga...@btinternet.com; tutor@python.org Sent: Thursday, 17 March, 2011 9:06:56 Subject: RE: [Tutor] time tak

Re: [Tutor] time taken to execute certain task

2011-03-17 Thread tee chwee liong
hi, i used profiler. but it gives 0 sec? is this expected? tq >>> profile.run('import math') 3 function calls in 0.000 CPU seconds Ordered by: standard name ncalls tottime percall cumtime percall filename:lineno(function) 10.0000.0000.0000.000 :0(set

Re: [Tutor] time taken to execute certain task

2011-03-17 Thread Alan Gauld
"tee chwee liong" wrote i would like to know the time taken to execute a certain task in python. i used time.time and time.clock and i see the time taken is different? what is the right method to use? Neither of those, either use timeit() or the Python profiler. They are both specifically

Re: [Tutor] time taken to execute certain task

2011-03-16 Thread Modulok
On 3/16/11, tee chwee liong wrote: > > hi, > > i would like to know the time taken to execute a certain task in python. i > used time.time and time.clock and i see the time taken is different? what is > the right method to use? > > import time > def testtime(num): > start=time.time() > #pr

Re: [Tutor] time taken to execute certain task

2011-03-16 Thread Jack Trades
On Wed, Mar 16, 2011 at 9:40 PM, tee chwee liong wrote: > hi, > > i would like to know the time taken to execute a certain task in python. i > used time.time and time.clock and i see the time taken is different? what is > the right method to use? > > import time > def testtime(num): > start=