### TooDumbToWin's blog

By TooDumbToWin, history, 3 years ago, ,

I ran these codes in custom invocation and got weird running times.

#include<bits/stdc++.h>
using namespace std;
int main(){
//Hi
for(int i=0;i<5000000;i++)cout<<i<<" ";
return 0;
}



Run time: 2448 ms

#include<bits/stdc++.h>
using namespace std;
int main(){
for(int i=0;i<5000000;i++)cout<<i<<" ";
return 0;
}



Run time: 2901 ms

Can anyone explain why adding comment is having significant impact on running times?

PS: Changing comment affected run time slightly as well.

•
• +32
•

 » 3 years ago, # |   +24 I guess it should just be difference between each runs. And codeforces caches your submission so if you submit one multiple times, it will return the same result.
•  » » 3 years ago, # ^ |   0 "I guess it should just be difference between each runs." I didn't get you. Can you please rephrase the statement?
•  » » » 3 years ago, # ^ |   +5 Due to dynamic CPU frequency, server load or some other reasons, time required for processing the same data by identical program may varies. As a result, several runs of a program may result different time consumed.Sorry for my bad English, hope this makes more sense.
•  » » » » 3 years ago, # ^ |   0 As Laakeri has mentioned, the difference is quite high (450 ms).
•  » » » » » 3 years ago, # ^ | ← Rev. 2 →   +5 This extent of difference is possible, at least on my machine (the result of running OP's program):
•  » » » » » » 3 years ago, # ^ |   0 So I can get AC/TLE with same code depending upon server status? That's not really good. :/
•  » » 3 years ago, # ^ |   +23 Online judge should not be so unstable that time difference between runs of the same program is over 400 ms.
 » 3 years ago, # |   +16 Tried it 8 times. If I change the comment for "Petr" it works.
•  » » 3 years ago, # ^ |   +8 CodeForces doesn't recompile your code if it's the same (at least in some time window)so tried 8 times may mean that result just was cached
•  » » » 3 years ago, # ^ |   0 Took that into account. I tried it on different windows and making changes on the code.