cProfile helps you to understand how often and how long parts of a programm are executed. Here is an example:
#!/usr/bin/env python import cProfile import PyTango name = "d1_mot01" def func( mot): p = PyTango.DeviceProxy( mot) print( "pos", p.position) return if __name__ == "__main__": cProfile.run("func( name)")
The output:
$ python pTest.py pos 14.0 89 function calls in 0.006 seconds Ordered by: standard name ncalls tottime percall cumtime percall filename:lineno(function) 1 0.000 0.000 0.006 0.006 <string>:1(<module>) 1 0.000 0.000 0.000 0.000 device_proxy.py:126(__check_read_attribute) 1 0.000 0.000 0.000 0.000 device_proxy.py:136(__init_device_proxy_internals) 5 0.000 0.000 0.000 0.000 device_proxy.py:139(<genexpr>) 4 0.000 0.000 0.000 0.000 device_proxy.py:145(__DeviceProxy__get_cmd_cache) 4 0.000 0.000 0.000 0.000 device_proxy.py:152(__DeviceProxy__get_attr_cache) 3 0.000 0.000 0.000 0.000 device_proxy.py:159(__DeviceProxy__get_pipe_cache) 1 0.003 0.003 0.003 0.003 device_proxy.py:166(__DeviceProxy__init__) 1 0.000 0.000 0.000 0.000 device_proxy.py:174(__DeviceProxy__get_green_mode) ...