Execution Time Info!

How to know the execution time of my program ?

  • Execution time is displayed just below green tick(AC) which you see when your code is correct.
  • You can click on desired solved problem displayed on your account page, now that will display whole chart of your submissions for that particular problem.

@wonder >> I would give an example for what @bit_cracker007 mentioned.

You can insert this code snippet before input.

    time_t start = clock();

and then you can write this at the end of printing output

	time_t end = clock();
	printf("Time: %.2lf sec\n", (end-start)/double(CLOCKS_PER_SEC));

Then you should run the program with redirecting an input test file (assuming that you have created it beforehand), and then you can observe the output at the screen itself OR you can redirect output to some file if the number of test cases is huge!

For example:

wonder@ubuntu:~$ gcc -o sample sample.c
wonder@ubuntu:~$ ./sample < testinput.in > testoutput.out

Or you can also use the C function freopen() in the corresponding mode (r or w) for the corresponding task. Example:


Note: You must have to include the header ctime in C++ (time.h in C) for using the clock() and time_t


i am using dev c++,so can’t it be calculated there??

Try codeblocks. However you may use clock() function in <time.h> to calculate time elapsed in executing a block of code.

Useful Links :