Re: time.time or time.clock
- From: Fredrik Lundh <fredrik@xxxxxxxxxxxxxx>
- Date: Mon, 14 Jan 2008 20:30:15 +0100
dwblas@xxxxxxxxx wrote:
"""
<snipped>
time.clock() isn't high enough resolution for Ubuntu, and time.time()
isn't > high enough resolution on windows.
Take a look at datetime. It is good to the micro-second on Linux and
milli-second on Windows.
datetime.datetime.now() does the same thing as time.time(); it uses the gettimeofday() API for platforms that have it (and so does time.time()), and calls the fallback implementation in time.time() if gettimeofdat() isn't supported. from the datetime sources:
#ifdef HAVE_GETTIMEOFDAY
struct timeval t;
#ifdef GETTIMEOFDAY_NO_TZ
gettimeofday(&t);
#else
gettimeofday(&t, (struct timezone *)NULL);
#endif
...
#else /* ! HAVE_GETTIMEOFDAY */
/* No flavor of gettimeofday exists on this platform. Python's
* time.time() does a lot of other platform tricks to get the
* best time it can on the platform, and we're not going to do
* better than that (if we could, the better code would belong
* in time.time()!) We're limited by the precision of a double,
* though.
*/
(note the "if we could" part).
</F>
.
- References:
- time.time or time.clock
- From: Ron Adam
- Re: time.time or time.clock
- From: dwblas
- time.time or time.clock
- Prev by Date: help with slicing/replacing matrix sections.
- Next by Date: SyntaxError: 'import *' not allowed with 'from .'
- Previous by thread: Re: time.time or time.clock
- Next by thread: Re: time.time or time.clock
- Index(es):
Relevant Pages
|