-
-
Notifications
You must be signed in to change notification settings - Fork 30.9k
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
Add time.thread_time() #76206
Comments
Currently, the time module has time.process_time(), a cross-platform function for getting per-process elapsed CPU time. Similarly, we could expose time.thread_time(), to get per-thread elapsed CPU time. Currently, you would need ctypes hacks to call GetThreadTimes(), which is not very nice. |
Would it be possible to not provide the function if it's not supported by a platform? Do you know platforms which don't support time.thread_time()? Do you want to add time.thread_time_ns() with nanosecond resolution (PEP-564) ? I suggest to add it to be consistent with time.process_time(). |
It seems like macOS doesn't implement CLOCK_THREAD_CPUTIME_ID but provides thread_info() which can be used by suming user and system times. |
Le 15/11/2017 à 02:48, STINNER Victor a écrit :
Probably, yes.
Any POSIX platform which doesn't have CLOCK_THREAD_CPUTIME_ID? It's an
Yes, I think so.
I don't have a macOS machine to test on, though :-) |
I can work on the macOS implementation, once your PR will be merged. |
Le 15/11/2017 à 22:06, STINNER Victor a écrit :
Great! |
Should I leave this open for you to work on the macOS implementation, Victor? |
I opened bpo-32093 for macOS. I close this one. Nice enhancement, I already like this new clock ;-) |
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:
bugs.python.org fields:
The text was updated successfully, but these errors were encountered: