LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (https://www.linuxquestions.org/questions/programming-9/)
-   -   how to accurately measure processing time (https://www.linuxquestions.org/questions/programming-9/how-to-accurately-measure-processing-time-87974/)

rasselin 09-01-2003 09:57 AM

how to accurately measure processing time
 
Hi,

I writing a packet processor that takes one packet from 1 to n distinct streams sequentially, and processes them one at a time. How can I *accurately* measure the packet processing delay for each individual packet?

Each packet stream is continuous, but they are not synchronous, i.e. for each stream, the arrival time of the first bit of each packet is different.

For example, when processing the first packet, I would like to know how much time is spent with the actually processing of that packet....So I don't want to include any time when the process gets swapped out etc. For this reason, I don't want to simply get the system time before and after the function.

I hope my question is clear, but please ask me to clarify if it isn't.

Thank you,
Ramy

Hko 09-01-2003 11:00 AM

Try using the "GNU Profiler" (command is "gprof"). Its' made especially for these kind of things. I've no experience using it, but I think it the best (only?) way to do this. Not including the time when a process gets swapped out, may be difficult or impossible, but I'm not sure about this.

See "man gprof". Also the free-downloadable book "Advanced Linux Programming" (New Riders), Appendix A3 has an introduction to gprof.

You can download the book, chapter by chapter here:

http://www.advancedlinuxprogramming.com/alp-folder

rasselin 09-01-2003 11:25 AM

Thanks,

I thought of using the profiler, except that I would like the information at run-time...I'm not just trying to optimize my code.

I came up with this method:

I can call my function as a separate process instead. Then (somehow) have that process access its it's own processor descriptor and get access to the per_cpu_utime and per_cpu_stime fields, which are the number of ticks the process is running in user and kernel mode. Does anyone think this will work?

Also, I think what i'm doing is similar to the linux time function...but I can't seem to locate the source code for that.

Any comments or ideas appreciated!

Ramy

Hko 09-01-2003 11:45 AM

Quote:

Originally posted by rasselin
Also, I think what i'm doing is similar to the linux time function...but I can't seem to locate the source code for that.
You can get it here:

http://ftp.debian.org/debian/pool/ma....7.orig.tar.gz

<edit>
The link is to the sources of the time program.
Did really want the function? Is suppose that's in the glibc sources.
</edit>


All times are GMT -5. The time now is 12:48 AM.