Re: Timing

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



I dunno how accurate it is. Maybe it's just the number of slices multiplied by something.

Ad.

Hayim Shaul wrote:


man clock(3) read:

"
DESCRIPTION
The clock() function returns an approximation of processor time used by
the program.

RETURN VALUE
The value returned is the CPU time used so far as a clock_t; to get the
number  of  seconds  used,  divide by CLOCKS_PER_SEC.  If the processor
time used is not available or its  value  cannot  be  represented, the
function returns the value (clock_t)-1.
"

It seems to me that this is what you are looking for.
CLOCKS_PER_SEC is set to 1,000,000 on all machines I worked with.

Is this not acurate enough?
Or are you bothered by the word "approximation" in the description?

Hayim.

PS. I think it would be better to have the kernel-newbies CC-ed so others will be able to reference these correspondence.



On Tue, 29 Nov 2005, Adrian May wrote:

Nope. I wanna know exactly how much time my process has consumed, not including time I was scheduled out.
Ad.

Hayim Shaul wrote:


Is clock() what you mean?


On Mon, 28 Nov 2005, Adrian May wrote:

Hi folks,

I don't know whether I have to hack the kernel for this or not, but figured you lot would know.

I want very accurate timing inside my app. That means, my process will ask for it's exact age at various times. This age should not include times when some other process was scheduled, but it should include the overhead of the timing itself, which gets done by my process. I want it to be high performance because I'll be doing it very often indeed. Function-level profiling is not enough because I need the time spent inside one specific function in particular, but separated out according to a parameter to that function. (Basically it's a VM that hosts zillions of tiny scripts and wants to keep perfect accounts about time used by all of them and that used by the VM itself).

I think that poking about in /proc would be too slow, but I bet the kernel knows how many jiffies my process has had, and if I could figure out what time (in usecs) my current slice started I could use the usec timer to figure out how old this slice is and work out the final answer that way. Or maybe there's a better strategy. I need it really accurate and fast though - ideally in processor cycles, but I somehow need to exclude the times I'm scheduled out.

Any ideas?
Thanks in advance,
Adrian.

BTW - I'll also need interval timers to terminate greedy scripts but they don't have to be all that accurate.





--
Kernelnewbies: Help each other learn about the Linux kernel.
Archive:       http://mail.nl.linux.org/kernelnewbies/
FAQ:           http://kernelnewbies.org/faq/


+++++++++++++++++++++++++++++++++++++++++++
This Mail Was Scanned By Mail-seCure System
at the Tel-Aviv University CC.


--
Kernelnewbies: Help each other learn about the Linux kernel.
Archive:       http://mail.nl.linux.org/kernelnewbies/
FAQ:           http://kernelnewbies.org/faq/




+++++++++++++++++++++++++++++++++++++++++++
This Mail Was Scanned By Mail-seCure System
at the Tel-Aviv University CC.





--
Kernelnewbies: Help each other learn about the Linux kernel.
Archive:       http://mail.nl.linux.org/kernelnewbies/
FAQ:           http://kernelnewbies.org/faq/


[Index of Archives]     [Newbies FAQ]     [Linux Kernel Mentors]     [Linux Kernel Development]     [IETF Annouce]     [Git]     [Networking]     [Security]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux SCSI]     [Linux ACPI]
  Powered by Linux