Download your favorite Linux distribution at LQ ISO.
Go Back > Forums > Linux Forums > Linux - Distributions > Slackware
User Name
Slackware This Forum is for the discussion of Slackware Linux.


  Search this Thread
Old 02-26-2007, 08:04 PM   #1
Registered: Jun 2006
Location: Washington, DC, USA
Distribution: Slackware
Posts: 41

Rep: Reputation: 15
Determine program's runtime

Is there any way to determine the time it took a program to execute?

I am trying to test a few methods of doing a calculation, and I'd like to find out which is the fastest.
Old 02-26-2007, 08:14 PM   #2
LQ Guru
Registered: Nov 2004
Location: San Jose, CA
Distribution: Ubuntu
Posts: 8,507

Rep: Reputation: 124Reputation: 124
Prefix execution of the program with "time".
Old 02-26-2007, 08:26 PM   #3
Registered: Mar 2006
Posts: 381

Rep: Reputation: 30
time, gprof and gcov.

gprof needs profiling (gcc -pg)

gcov needs "-g -fprofile-arcs -ftest-coverage"

Have fun!
Old 03-14-2007, 02:02 AM   #4
LQ Newbie
Registered: Mar 2007
Posts: 5

Rep: Reputation: 0
Thumbs up hey did u get the solution

Hi Dear friend...
I want to write a program to find the TOTAL PROGRAM EXECUTION TIME in C.
Note: While executing the program SYSTEM TIME willl change... Even though it has to give the correct out put....
So please send me the way u have done.

Please reply..back.

Thanks & regards
Old 03-14-2007, 10:51 AM   #5
LQ Newbie
Registered: Mar 2007
Posts: 5

Rep: Reputation: 0

Originally Posted by Matir
Prefix execution of the program with "time".

hi.. friend

can u explain me in detail by taking an example with small C code
Old 03-14-2007, 02:42 PM   #6
LQ Guru
Registered: Oct 2005
Location: $RANDOM
Distribution: slackware64
Posts: 12,928
Blog Entries: 2

Rep: Reputation: 1287Reputation: 1287Reputation: 1287Reputation: 1287Reputation: 1287Reputation: 1287Reputation: 1287Reputation: 1287Reputation: 1287
In C ? Well, it's not as easy as you might think. Take a look at the source code for the 'time' program:

So, basically you want to re-invent the wheel. 'time' is written in C and it does what you are asking .... what more do you want.

Last edited by H_TeXMeX_H; 03-14-2007 at 02:43 PM.


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 do i determine my IP address? How do i determine my host name? jwymore Linux - Networking 5 02-07-2007 09:57 AM
Looking for a few program's. Budman21901 Linux - Software 8 10-27-2005 03:00 PM
Suse certification program's hansi umayangan SUSE / openSUSE 1 07-01-2005 11:53 AM
C: Getting program's output MylesCLin Programming 4 02-24-2005 05:06 PM
How do I run program's with WINE? kaber Linux - Software 3 09-09-2004 03:41 PM

All times are GMT -5. The time now is 04:27 PM.

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