libs-team
                                
                                 libs-team copied to clipboard
                                
                                    libs-team copied to clipboard
                            
                            
                            
                        Feature: A separate type for measuring thread time in std::time module
Had this thought regarding if we can infer the time it takes for object to be executed in a given OS thread context, instead of relying on the std::time::Instant to obtain the time elapsed which won't take into account things such as context switch etc etc, therefore I would like to propose a thought  ThreadTime a type which may keep track of the time spent by itself on a given thread context excluding all the context switching mechanism..
internally it may look like so
pub struct ThreadTime { 
    duration: ThreadDuration, 
    thread: SomeThreadTypeRecorder
}
through this we can avoid using ThreadLocal<T> types directly which may wrap duration between itself, and then maybe we continue the computation, this can be especially useful if you wish to use it in the some struct where you wish to track time in precision.
and should have !Sync enabled, let me know is it a useful idea ?
Iam not sure though whether this can be made platform agnostic ? and also O.S agnostic too.
I'm not sure I understand the use case for something like this, nor do I understand the mechanism for which something like this would be implemented. Can you flesh both of those things out a bit more please? Real world examples would help. It would also help to describe why a thread local is an inappropriate solution.
I assume you mean something like CLOCK_THREAD_CPUTIME_ID? This is definitely possible to implement, at least on UNIX. Do you have a concrete problem in mind that you would like to use this for?
There's the cpu-time crate and possibly others.
What would be the value of having this in std instead of a crate?