Message158545
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. |
|
Date |
User |
Action |
Args |
2012-04-17 11:55:30 | vstinner | set | recipients:
+ vstinner, lemburg, neologix |
2012-04-17 11:55:30 | vstinner | set | messageid: <1334663730.64.0.66109856995.issue14428@psf.upfronthosting.co.za> |
2012-04-17 11:55:28 | vstinner | link | issue14428 messages |
2012-04-17 11:55:28 | vstinner | create | |
|