Just recently I was trying to solve a problem but repeatedly encountered TLE verdict. This was while I was using Java 7.
Just thought I'd give it a shot and submitted the ditto same code but in Java 8. Works like a charm.
Java 7 submission Java 8 submission
And it's not some minor difference. There's a running time difference of > 2s, with Java 8 being the faster one.
I'm really curious as to why this happens. Yes, I know some kind of optimization is happening but what kind? A 2s difference is a LOT so it is non-trivial. Somebody explain?
Lol very interesting. Thanks for sharing this! No idea what's going on :o
Yes-yes, of course.
http://codeforces.net/contest/20/submission/6451711
http://codeforces.net/contest/20/submission/6484516
LOL, It's too unpredictable!
conclusion: time = time + 2 * (8-7) * (-1)^rand.nextInt(1)
i got the result conversely. in my submission java 6 is the fastest.
java 6 java 7 java 8
You can't compare performance with such trivial code. If you submit it multiple times, you will probably see execution time fluctuate wildly.
You should solve some computationally expensive problem and then test the performance.
I might be wrong, but it might be that JAVA 8 always uses "server" VM when Java 7 defaults to "client".