How to tell how long my program has ran?

i'm using ubuntu and G++ 4.6.3 compiler. I compiled the code and create "program1" file

Now i exceute the program with an "./program1" command and i want to see how long it took to run the program? how do i do this? what command or parameter do i need to type so it will tell me how long it took my program to run?
$ time ./program1
just for your info, maybe you should ask this in "UNIX/Linux Programming" subsection...
how do i check this in windows?
Hi all
i think you can not try it in MS widows,its about Unix(Linux) terminal. you can use time.h functions to check how long take your program too run.
Have Nice Life
tdk93, if you want to do it in windows, use codeblocks, it uses the ming32 compiler with is basically a GNU gcc compiler. Codeblocks has a function that lets you run the program and it tells you how long it's been running
You could run a batch file:
date /T
time /T
program1
time /T
date /T

Wallclock time, but the resolution is only by minute.

You can print current time from the program at start and at end, because you can edit and recompile.

Task Manager shows CPU Time for currently running processes. If you do getch() at the end, cpu usage will not add much while it waits, but you have time to read the accumulated CPU usage.
Last edited on
the problem with wall-clock time is that it is counting the time that the process manager and other programs also use.
You probably want to know how much your program was executing (user time), that you can get with clock()
Topic archived. No new replies allowed.