Why is OJ's Java test harness so slow?


  • 0
    B

    I have been tinkering around with trying to get my solutions in Java to near my C++ solutions and I've come to the conclusion that OJ is doing something wrong. I don't know if they are including JVM spin up time or what, but there is no reason something that takes 20ms in C++ takes 200 in Java. Perhaps in large applications that are having to do lots of memory management, you would see increases likes this but in a silly little program iterating over an array and doing multiplications? For example, Factorial Trailing Zeroes solution same in C++ and Java:

        int sum = 0;
        while (n > 4){
            sum = sum + n/5;
            n = n/5;
        }
        return sum;
    

    Java 380ms
    C++ 44ms

    Can anyone shed light on this?


  • 0
    R

    Can you monitor how long your C++ version is taking on you local machine vs your Java version ? If both are taking almost the same time then that might be a good indicator of an issue in OJ.


Log in to reply
 

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.