Why does line_profiler in python not add up the times correctly?
Question: I am new to the line_profiler package in python. Am I reading the result
incorrectly, or shouldn't the components in the output below add up to 1.67554
seconds? Instead, they add up to 3.918 seconds (2426873 microseconds + 1491105
microseconds). Thanks!

    
    
    # test.py
    import numpy as np
    def tf():
        arr = np.random.randn(3000,6000)
        np.where(arr>1,arr,np.nan)
    
    
    import test
    %lprun -f test.tf test.tf()
    
    Timer unit: 4.27654e-07 s
    
    File: test.py
    Function: tf at line 9
    Total time: 1.67554 s
    
    Line #      Hits         Time  Per Hit   % Time  Line Contents
    ==============================================================
         9                                           def tf():
        10         1      2426873 2426873.0     61.9      arr = np.random.randn(3000,6000)
        11         1      1491105 1491105.0     38.1      np.where(arr>1,arr,np.nan)
    


Answer: You misread the time there; those are _not microseconds_.

From the [documentation](http://pythonhosted.org/line_profiler/):

> Time: The total amount of time spent executing the line **in the timer's
> units**. In the header information before the tables, you will see a line
> "Timer unit:" **giving the conversion factor to seconds**. It may be
> different on different systems.

Emphasis mine. Your output shows each _Timer unit_ is about 0.428
microseconds. The totals match if you multiply the units with the _Timer unit_
value:

    
    
    >>> unit = 4.27654e-07
    >>> 2426873 * unit + 1491105 * unit
    1.675538963612
    

