STINNER Victor <victor.stin...@gmail.com> added the comment:

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()
            thread.start()
            thread.join()
            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.

----------

_______________________________________
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue14428>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to