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.

Author vstinner
Recipients lemburg, neologix, vstinner
Date 2012-04-17.11:55:28
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <>
FreeBSD doesn't provide CLOCK_PROCESS_CPUTIME_ID, but CLOCK_PROF. CLOCK_PROF can be used instead of getrusage(), its precision can be read using clock_getres(). Something like "> #if defined(CLOCK_PROF) && defined(__FreeBSD__)" can be used. (By the way, "#if defined(__linux__)" may be enough)

I read somewhere than CLOCK_PROF is the user+system CPU time of the *current thread* on OpenBSD. I can be checked by the following unit test:

        def test_process_time_threads(self):
            class BusyThread(threading.Thread):
                def run(self):
                    timeout = monotonic() + 1.0
                    loops = 1
                    while monotonic() < timeout:
                        i = 0
                        while i < loops:
                            i += 1
                        loops *= 2

            t1 = process_time()
            thread = BusyThread()
            t2 = process_time()
            self.assertGreater(t2 - t1, 0.9)


perf_counter() should remember if win32_perf_counter() failed or not, as the pseudo-code of the PEP. I prefer to leave clock() unchanged to keep backward compatibility.
Date User Action Args
2012-04-17 11:55:30vstinnersetrecipients: + vstinner, lemburg, neologix
2012-04-17 11:55:30vstinnersetmessageid: <>
2012-04-17 11:55:28vstinnerlinkissue14428 messages
2012-04-17 11:55:28vstinnercreate