ANN: a new utility for Python developers

Skip Montanaro skip at pobox.com
Tue Aug 21 11:54:22 EDT 2001


    Erno> there are 2 things here and i am not sure which ones we are
    Erno> disagreeing about.

Nor am I.  From my perspective, I want time.time() to return the wall clock
time and time.clock() to tell me how much CPU my program has used since it
started.  If both of those aren't available on all platforms, then obviously
something will have to be fudged.  The time module is supposed to be a very
thin wrapper around various time-related C library functions.  time.time()
already uses gettimeofday() (if it's available) to do its dirty work.
Failing that, it falls back to ftime() or (last choice) time().
time.clock() uses the clock() library function on systems that have it.  On
Windows it uses QueryPerformanceCounter().  If neither case holds,
time.clock() simply isn't available.  I suspect that's the best that can be
done right now.  I think if there was a better solution, Guido and friends
would have found it by now.

    Erno> 1) it is usually better to use gettimeofday(2) than times(2) on
    Erno>    unix for timing code because times(2) has poor resolution and
    Erno>    the user/system time numbers are frequently gibberish.

    Erno> 2) the python time.clock() should return information based on
    Erno>    gettimeofday(2) and not times(2) on unix.

times() is not used anywhere in timemodule.c.

Skip




More information about the Python-list mailing list