Submit 4 times with same code, but runtime is not same...


  • 0
    G

    I Submit 4 times with same code, but runtime is not same,like this:

    3ms
    5ms
    3ms
    2ms
    why...
    is the tests not same eveytime ?


  • 0
    G

    The runtime will not always be the same, it varies greatly on the available system resources and/or network latency (e.g leetcode is calling another backend service from its judger), especially when the runtime is measured at 1ms level. An example: even when you boot your laptop, it may not always be ready within the same amount of time, right? ;)


  • 0
    G

    thank you~~~


  • 0
    C

    For Java and C#, my numbers are all over the place - the same code can be faster than 75% of all submissions or only faster than 25% of all submissions depending on the weather.

    They should test on virtual hardware so they can actually count the number of CPU instructions, memory allocations, etc and then calculate a deterministic representative value based on observed norms. That would give a truer picture of the efficiency.


Log in to reply
 

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