Question: I have a python program defined by a function `myFunc(m,n)`

Basically, the function contains two for loops.

```
def myFunc(m, n) : 
    for i in range(m) : 
        for j in range(n) : 
            # do it ...
    return 

```

I would like to calculate the time elapsed for `m,n=20,20`

I do it like this:

```
start_time = time.time()
b = myFunc(m,n)
elapsed_time = time.time() - start_time
print elapsed_time

```

The result is 0.0 almost always. Why?

Answer: 
[Per the `time.time` docs](https://docs.python.org/3/library/time.html#time.time), 

> 
> even though the time is always returned as a floating point number, not all systems provide time with a better precision than 1 second.
> 
> 
> 

So if `myFunc` takes less than a second and you are using such an OS, then the difference between two calls of `time.time` could be 0.0.

You could use `timeit.default_timer` instead of `time.time`. `timeit.default_timer` will choose the best timer (`time.time`, `time.clock` or `time.perf_counter`) for your system.

Also note that [the timeit module](https://stackoverflow.com/q/8220801/190597) offers more accurate ways to test the performance of code snippets.
Because `time.time() - time.time()` will be `0.0` when `myFunc` doesn't take very long.