How to check compile time?


Is there a way (I know there must be one, only I’m not aware) to check the program memory, compile time and call stack in Code::Blocks with MinGW 4.7.2?


Probably you are not interested in compile time, but running time, right? Also call stack, you want to know how deep the call stack is or what or max deep during execution?

By compile time, I mean I want to know how long the code took to compile? I was trying to solve this trivial question. But I exceed the time limit every time. I saw some of the other user’s solutions but still I don’t understand why my code exceeds time limit.

Compilation is a process, when compiler compiles your source code (.cpp) to executable (.exe) and I think you are not interested in this time (TopCoder has time limit for compile time in marathon matches for example).

You are using cin and cout which is slow and this problem targets this, try to read some threads about this in forum…

1 Like

Hello @Fleptic

Compilation of code is the part that is done to create the executable or object files, It is generally parsing of the code and syntax analyzing which is done by MinGW or some gcc compiler.

Now after creation of the exe file, the time which that exe takes to process your input into the required output is the actual time which is check by the site.
I saw you submissions of TLE, that means your code is taking much time to process the input, it is during runtime. There is no work of compile time.

Trying using some fast i/o operations, use of fread() and fwrite() will help you to get accept the problem or you can use the facility provided by the codechef to view and learn from the codes of others after a lot of tries.

Here is the sample code from which you can check how much time is taken to process your code.

using namespace std;
int main() {
	clock_t start_time,end_time;
	start_time = clock();
	int i;
	// your process
	end_time = clock();
	cout<<"Time Taken"<<(end_time - start_time)/CLOCKS_PER_SEC<<endl;
	return 0;

But remember, process time depends on processor speed, so it may be different for different machines.

Keep Programming and Enjoy


Thanks! using scanf() and printf() worked.

Remember to use those methods when coding here :wink:

Now, I could submit it. And thanks for explaining me about my misconception about compile time (i.e., runtime).


BTW how can I check the time required to process the input into required outputs in gcc?


@fleptic Edited my answer :slight_smile:

I have to add one more warning, you can find time to process input, but it is also input dependent. It’s natural, that for bigger input it takes longer…