This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: os.times() returns incorrect value
Type: behavior Stage:
Components: Library (Lib) Versions: Python 2.5
process
Status: closed Resolution: rejected
Dependencies: Superseder:
Assigned To: Nosy List: facundobatista, georg.brandl, kwatch
Priority: normal Keywords: patch

Created on 2008-02-29 01:59 by kwatch, last changed 2022-04-11 14:56 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
posixmodule.patch kwatch, 2008-02-29 02:08 patch to Modules/posixmodule.c
Messages (4)
msg63116 - (view) Author: Facundo Batista (facundobatista) * (Python committer) Date: 2008-02-29 02:03
What?

Why you say that? What are you doing? What do you get? What do you
expect? In which version of Python and in which Platform are you working?
msg63117 - (view) Author: makoto kuwata (kwatch) Date: 2008-02-29 02:08
I'm sorry to put empty submit.

os.time() returns incorrect value.

test.py:

    def f(n):
      if n <= 0:
          return 1
      else:
          return f(n-1) + f(n-2)
    
    import os
    t1 = os.times()
    f(34)
    t2 = os.times()
    
    utime = t2[0] - t1[0]
    stime = t2[1] - t1[1]
    total = utime + stime
    
    print "utime %.4f, stime %.4f, total %.4f" % (utime, stime, total)

result:

    $ time python bench.py
    utime 38.6333, stime 0.1000, total 38.7333
    
    real    0m23.787s
    user    0m23.211s
    sys     0m0.138s

This shows that real time is only 23.8 seconds, but os.times()
reports that user time is over 38 seconds.

This is due to bug of Modules/posixmodule.c.

Environment: python 2.5.2, MacOS X 10.4 Tiger, GCC 4.0
msg63118 - (view) Author: makoto kuwata (kwatch) Date: 2008-02-29 02:16
See
http://groups.google.com/group/comp.lang.python/browse_thread/thread/8032897a30781df/c656a79d4c3268a6
for details about this bug.
msg63137 - (view) Author: Georg Brandl (georg.brandl) * (Python committer) Date: 2008-02-29 14:09
Isn't that tracked in #1040026?
History
Date User Action Args
2022-04-11 14:56:31adminsetgithub: 46458
2008-02-29 14:09:42georg.brandlsetnosy: + georg.brandl
messages: + msg63137
2008-02-29 02:16:09kwatchsetmessages: + msg63118
2008-02-29 02:08:38kwatchsetfiles: + posixmodule.patch
keywords: + patch
messages: + msg63117
title: os.times() returns uncorrect value -> os.times() returns incorrect value
2008-02-29 02:03:04facundobatistasetstatus: open -> closed
resolution: rejected
messages: + msg63116
nosy: + facundobatista
2008-02-29 01:59:20kwatchcreate