Re: measuring a function time

2010-08-07 Thread Albert van der Horst
In article <4c5178ae$0$11091$c3e8...@news.astraweb.com>, Steven D'Aprano wrote: >On Thu, 29 Jul 2010 14:42:58 +0200, Matteo Landi wrote: > >> This should be enough >> >import time >tic = time.time() >function() >toc = time.time() >print toc - tic > >You're typing that in the i

Re: measuring a function time

2010-07-30 Thread MRAB
Albert Hopkins wrote: On Fri, 2010-07-30 at 14:28 +0200, Hrvoje Niksic wrote: Steven D'Aprano writes: On Thu, 29 Jul 2010 14:42:58 +0200, Matteo Landi wrote: This should be enough import time tic = time.time() function() toc = time.time() print toc - tic You're typing that in the interac

Re: measuring a function time

2010-07-30 Thread Albert Hopkins
On Fri, 2010-07-30 at 14:28 +0200, Hrvoje Niksic wrote: > Steven D'Aprano writes: > > > On Thu, 29 Jul 2010 14:42:58 +0200, Matteo Landi wrote: > > > >> This should be enough > >> > >import time > >tic = time.time() > >function() > >toc = time.time() > >print toc - tic > > >

Re: measuring a function time

2010-07-30 Thread Hrvoje Niksic
Steven D'Aprano writes: > On Thu, 29 Jul 2010 14:42:58 +0200, Matteo Landi wrote: > >> This should be enough >> >import time >tic = time.time() >function() >toc = time.time() >print toc - tic > > You're typing that in the interactive interpreter, which means the > timer is co

Re: measuring a function time

2010-07-29 Thread Rodrick Brown
Someone should port Perl's Benchmark.pm module to python that's such a useful module to measure a functions execution time and CPU usage. Sent from my iPhone 4. On Jul 29, 2010, at 3:43 PM, "Benjamin J. Racine" wrote: > I just use ipython's functions (that are themselves just calls to the tim

Re: measuring a function time

2010-07-29 Thread Benjamin J. Racine
I just use ipython's functions (that are themselves just calls to the time module functions) for timing my functions... Enter: %timeit? or %time At the Ipython command prompt to get started. Ben R. On Jul 29, 2010, at 7:43 AM, D'Arcy J.M. Cain wrote: > On Thu, 29 Jul 2010 08:45:23 -0400 > Jo

Re: measuring a function time

2010-07-29 Thread D'Arcy J.M. Cain
On Thu, 29 Jul 2010 08:45:23 -0400 Joe Riopel wrote: > On Thu, Jul 29, 2010 at 8:34 AM, Mahmood Naderan wrote: > > the output should be 7600 (s) for example. What is the best and easiest way > > to do that? > > Take a look at time.clock() I don't know if that's what he wants. The clock() metho

Re: measuring a function time

2010-07-29 Thread Mahmood Naderan
PM Subject: Re: measuring a function time This should be enough >>>import time >>>tic = time.time() >>>function() >>>toc = time.time() >>>print toc - tic On Thu, Jul 29, 2010 at 2:34 PM, Mahmood Naderan wrote: > Hi, > I want to measure a functio

Re: measuring a function time

2010-07-29 Thread Steven D'Aprano
On Thu, 29 Jul 2010 14:42:58 +0200, Matteo Landi wrote: > This should be enough > import time tic = time.time() function() toc = time.time() print toc - tic You're typing that in the interactive interpreter, which means the timer is counting the seconds while you're typing s

Re: measuring a function time

2010-07-29 Thread Joe Riopel
On Thu, Jul 29, 2010 at 8:34 AM, Mahmood Naderan wrote: > the output should be 7600 (s) for example. What is the best and easiest way > to do that? Take a look at time.clock() http://docs.python.org/library/time.html#time.clock "this is the function to use for benchmarking Python or timing algo

Re: measuring a function time

2010-07-29 Thread Matteo Landi
This should be enough >>>import time >>>tic = time.time() >>>function() >>>toc = time.time() >>>print toc - tic On Thu, Jul 29, 2010 at 2:34 PM, Mahmood Naderan wrote: > Hi, > I want to measure a function run time. I read > http://docs.python.org/library/time.html but I am confused and don't kno

measuring a function time

2010-07-29 Thread Mahmood Naderan
Hi, I want to measure a function run time. I read http://docs.python.org/library/time.html but I am confused and don't know which one is suitable. I don't know is daylight timing important or not or is Y2K issue important for my case or not I also don't know how epoch time is related to