Measuring ticks (or time) per threads

Phil maidenphil at hotmail.com
Wed Dec 4 16:52:59 PST 2013


On Wednesday, 4 December 2013 at 22:55:46 UTC, Rob T wrote:
> On Wednesday, 4 December 2013 at 20:12:41 UTC, Phil wrote:
>> Hi guys,
>>
>> I'd like to know if there is a way using the stdlib that I can 
>> measure the number of ticks that a thread has been working. I 
>> do mean the number of ticks that it has been ACTIVE, and not 
>> the noTicks since its creation.
>>
>> Thanks!
>> Phil
>
> The D core.thread lib could certainly have more functions added 
> to it.
>
> If you are using a posix compatible OS, check out
>
> core.sys.posix.sys.resource;
>
> Use this function to get runtime stats
> int getrusage(int, rusage*);
>
> For usage details, consult the manpage
> http://linux.die.net/man/2/getrusage
>
> The times returned are in seconds+msec but you can convert to 
> approx ticks using conversion functions in core.clock.
>
> As for Windows, I have no idea how to get this information, but 
> there's probably a way.
>
> --rt

That function sounds great. Unfortunately I am working on Windows 
so I guess I'll have to look into their API. I was hoping for a 
solution available in the std but if there isn't than there 
isn't. Thanks for you information!


More information about the Digitalmars-d-learn mailing list