Message158545
| Author |
vstinner |
| Recipients |
lemburg, neologix, vstinner |
| Date |
2012年04月17日.11:55:28 |
| SpamBayes Score |
-1.0 |
| Marked as misclassified |
Yes |
| Message-id |
<1334663730.64.0.66109856995.issue14428@psf.upfronthosting.co.za> |
| In-reply-to |
| Content |
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. |
|
History
|
|---|
| 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 |
|