LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 09-01-2003, 09:57 AM   #1
rasselin
LQ Newbie
 
Registered: Aug 2003
Location: Pennsylvania
Posts: 7

Rep: Reputation: 0
Question 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
 
Old 09-01-2003, 11:00 AM   #2
Hko
Senior Member
 
Registered: Aug 2002
Location: Groningen, The Netherlands
Distribution: Debian
Posts: 2,536

Rep: Reputation: 111Reputation: 111
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
 
Old 09-01-2003, 11:25 AM   #3
rasselin
LQ Newbie
 
Registered: Aug 2003
Location: Pennsylvania
Posts: 7

Original Poster
Rep: Reputation: 0
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
 
Old 09-01-2003, 11:45 AM   #4
Hko
Senior Member
 
Registered: Aug 2002
Location: Groningen, The Netherlands
Distribution: Debian
Posts: 2,536

Rep: Reputation: 111Reputation: 111
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>

Last edited by Hko; 09-01-2003 at 11:47 AM.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
how to do batch processing with time out? Franziss Programming 4 11-30-2005 10:17 PM
how can I measure how much real time is used to run an executable? markhod Linux - General 1 04-07-2005 04:41 AM
Can I somehow accurately measure the time a operation takes? Like 'unzip -x foo.zip'? brynjarh Linux - Newbie 9 08-18-2004 09:26 PM
How to measure the time to build a package? mullog Linux From Scratch 10 05-11-2004 11:23 AM
accurately measure time rasselin Programming 1 09-05-2003 05:18 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 02:32 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration