LinuxQuestions.org
Visit Jeremy's Blog.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 07-14-2008, 04:01 AM   #1
raedbenz
Member
 
Registered: Dec 2007
Posts: 93

Rep: Reputation: 15
compute execution time


HI,,,
is there a way to compute the execution time of a function,(i dont know any functions, system calls, debugger, etc..) under linux (i am using Ubuntu8.04).
e.g.In the code below, how to compute the execution time of myFunc()??
Code:
// Start of code
#include <stdio.h>

void myFunc(void){
printf("Hello World");
}

int main(void)
{
//some work
myFunc();
return 0;
}
// end of code
thanks
 
Old 07-14-2008, 07:37 AM   #2
smoked kipper
Member
 
Registered: May 2008
Location: UK
Distribution: Slackware,Slamd64
Posts: 81

Rep: Reputation: 15
Compile with profiling support (-pg option to gcc (-pg must be specified when linking too)) and use a tool like gprof to analyse the data. See gprof man page for details.
 
Old 07-15-2008, 12:26 PM   #3
raedbenz
Member
 
Registered: Dec 2007
Posts: 93

Original Poster
Rep: Reputation: 15
Quote:
Originally Posted by smoked kipper View Post
See gprof man page for details.
Hi,,
the gprof tool in order to get the information, the application should return from main() or call exit(). what if a program runs into a while loop all the time i.e. while(1)
how we can get over this issue to generate "gmon.out" ??
thanks

Last edited by raedbenz; 07-16-2008 at 03:24 PM.
 
  


Reply



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
command execution time minil Programming 10 08-20-2010 04:59 PM
how to find the time of execution anandkj Linux - Newbie 2 12-20-2007 02:27 AM
I want to know the program execution time daggulasreedhar Programming 6 03-15-2007 04:07 AM
commnad time execution caprianking2002 Linux - General 2 06-27-2006 03:01 AM
how to [time] the execution hq4ever Linux - General 8 07-03-2004 04:57 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 05:42 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