www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.learn - Measuring ticks (or time) per threads

reply "Phil" <maidenphil hotmail.com> writes:
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
Dec 04 2013
parent reply "Rob T" <alanb ucora.com> writes:
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
Dec 04 2013
parent reply "Phil" <maidenphil hotmail.com> writes:
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!
Dec 04 2013
next sibling parent "Rob T" <alanb ucora.com> writes:
On Thursday, 5 December 2013 at 00:53:00 UTC, Phil wrote:
 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!
You may find something in core.sys.windows.windows.d. My understanding is that it's not a full interface into the windows API, but enough may be there. --rt
Dec 04 2013
prev sibling parent reply "Rob T" <alanb ucora.com> writes:
Also please post a bug or enhancement issue for anything that you 
think ought to be included in the standard libs that isn't.

https://d.puremagic.com/issues/

--rt
Dec 04 2013
parent "Phil Lavoie" <maidenphil hotmail.com> writes:
On Thursday, 5 December 2013 at 06:22:35 UTC, Rob T wrote:
 Also please post a bug or enhancement issue for anything that 
 you think ought to be included in the standard libs that isn't.

 https://d.puremagic.com/issues/

 --rt
Done
Dec 05 2013