execution time doubt

how to calculate the time taken for a program to get compiled???

In Linux you can do(assuming your code is in c) :

time gcc -c YOUR-PROGRAM.c

the above command displays :

real xxxxx

user yyyyy

sys zzzzz

you can add (user+sys) time to get your compilation time

In windows :

you can use “-ftime-report” i.e:

gcc -s -O3 -ftime-report YOUR-PROGRAM.c -o YOUR-PROGRAM.exe

this gives the total compilation time at the end of report.

I think but I am not sure that same may be applied for java also.

If you want the execution time then in LINUX you can do

time ./a.out

and in windows you can do :

timeit -YOUR_PROGRAM.exe

1 Like