Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

os.times() returns incorrect value #46458

Closed
kwatch mannequin opened this issue Feb 29, 2008 · 4 comments
Closed

os.times() returns incorrect value #46458

kwatch mannequin opened this issue Feb 29, 2008 · 4 comments
Labels
stdlib Python modules in the Lib dir type-bug An unexpected behavior, bug, or error

Comments

@kwatch
Copy link
Mannequin

kwatch mannequin commented Feb 29, 2008

BPO 2205
Nosy @birkenfeld, @facundobatista
Files
  • posixmodule.patch: patch to Modules/posixmodule.c
  • Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.

    Show more details

    GitHub fields:

    assignee = None
    closed_at = <Date 2008-02-29.02:03:04.772>
    created_at = <Date 2008-02-29.01:59:20.315>
    labels = ['type-bug', 'library']
    title = 'os.times() returns incorrect value'
    updated_at = <Date 2008-02-29.14:09:42.223>
    user = 'https://bugs.python.org/kwatch'

    bugs.python.org fields:

    activity = <Date 2008-02-29.14:09:42.223>
    actor = 'georg.brandl'
    assignee = 'none'
    closed = True
    closed_date = <Date 2008-02-29.02:03:04.772>
    closer = 'facundobatista'
    components = ['Library (Lib)']
    creation = <Date 2008-02-29.01:59:20.315>
    creator = 'kwatch'
    dependencies = []
    files = ['9568']
    hgrepos = []
    issue_num = 2205
    keywords = ['patch']
    message_count = 4.0
    messages = ['63116', '63117', '63118', '63137']
    nosy_count = 3.0
    nosy_names = ['georg.brandl', 'facundobatista', 'kwatch']
    pr_nums = []
    priority = 'normal'
    resolution = 'rejected'
    stage = None
    status = 'closed'
    superseder = None
    type = 'behavior'
    url = 'https://bugs.python.org/issue2205'
    versions = ['Python 2.5']

    @kwatch kwatch mannequin added stdlib Python modules in the Lib dir type-bug An unexpected behavior, bug, or error labels Feb 29, 2008
    @facundobatista
    Copy link
    Member

    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?

    @kwatch
    Copy link
    Mannequin Author

    kwatch mannequin commented Feb 29, 2008

    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

    @kwatch kwatch mannequin changed the title os.times() returns uncorrect value os.times() returns incorrect value Feb 29, 2008
    @kwatch
    Copy link
    Mannequin Author

    kwatch mannequin commented Feb 29, 2008

    @birkenfeld
    Copy link
    Member

    Isn't that tracked in bpo-1040026?

    @ezio-melotti ezio-melotti transferred this issue from another repository Apr 10, 2022
    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
    Labels
    stdlib Python modules in the Lib dir type-bug An unexpected behavior, bug, or error
    Projects
    None yet
    Development

    No branches or pull requests

    2 participants