-   Slackware (
-   -   Determine program's runtime (

kd5pbo 02-26-2007 08:04 PM

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.

Matir 02-26-2007 08:14 PM

Prefix execution of the program with "time".

erklaerbaer 02-26-2007 08:26 PM

time, gprof and gcov.

gprof needs profiling (gcc -pg)

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

Have fun!

daggulasreedhar 03-14-2007 02:02 AM

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

daggulasreedhar 03-14-2007 10:51 AM


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

H_TeXMeX_H 03-14-2007 02:42 PM

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.

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