bofh19 / yappi

Automatically exported from code.google.com/p/yappi
MIT License
0 stars 0 forks source link

Native calls are not recognized by default #44

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
Consider following code, testmod.py:
import time

def foo():
    bar()
    bar()
    bar()

def goo():
    bar()
    bar()

def bar():
    time.sleep(0.1)

def test():
    foo()
    goo()

tested with following yappi invokation:
In [1]: import yappi, testmod
In [2]: yappi.set_clock_type("WALL")
In [3]: yappi.start(); testmod.test(); yappi.stop()
In [4]: yappi.get_func_stats().save("wall-sleep.callgrind", "callgrind")

Open resulting file in kcachegrind.

test/foo/goo/bar are visible, but time.sleep, where all the time is actually 
spent is displayed as "unknown".

Original issue reported on code.google.com by dim...@gmail.com on 4 Feb 2014 at 1:14

Attachments:

GoogleCodeExporter commented 9 years ago
time.sleep() is a builtin function. You should set builtins=True in start() 
call:
yappi.start(builtins=True) then time.sleep will be shown:

Clock type: wall
Ordered by: totaltime, desc

name                                    #n         tsub      ttot      tavg
issue44.py:21 test                      1          0.000021  0.499722  0.499722
issue44.py:17 bar                       5          0.000024  0.499684  0.099937
time.sleep                              5          0.499660  0.499660  0.099932
issue44.py:6 foo                        1          0.000011  0.299701  0.299701
issue44.py:12 goo                       1          0.000005  0.199999  0.199999

Original comment by sum...@gmail.com on 4 Feb 2014 at 2:40

GoogleCodeExporter commented 9 years ago

Original comment by sum...@gmail.com on 4 Feb 2014 at 2:40

GoogleCodeExporter commented 9 years ago

Original comment by sum...@gmail.com on 4 Feb 2014 at 2:43

GoogleCodeExporter commented 9 years ago

Original comment by sum...@gmail.com on 4 Feb 2014 at 2:43

GoogleCodeExporter commented 9 years ago
Indeed! tested; works; confirming that suggested kwarg sovles the issue.

Original comment by dim...@gmail.com on 4 Feb 2014 at 2:43

GoogleCodeExporter commented 9 years ago

Original comment by sum...@gmail.com on 4 Feb 2014 at 2:44