2011/4/2 Emmanuel Blot <[email protected]>:
> Hello,
> Enumerating USB devices on the host buses may be quite time consuming.
> I need to enumerate these devices a couple of times at startup, and pyusb
> does not cache the results.
PyUSB always will delegate these things to the backend.
> The net performance penalty here is 0.7 second per "core:find" call, which
> slow down my application start up time.
> What would be the recommended way to implement some kind of cache so that
> the physical enumeration only occurs once during a Python runtime session?
I think the best way is to provide your own backend. You can inherit
from an existing
one and just replace the enumerate_devices method.
> Moreover, is there a simple way to disable the methodloggers in order to
> save time as well?
You must patch the code, as far as I know there is no other way. What
can be done is to
optimize the methodloggers.
> Thanks,
> Manu
> ncalls tottime percall cumtime percall filename:lineno(function)
> 1 0.000 0.000 2.242 2.242 <string>:1(<module>)
> 1 0.002 0.002 2.242 2.242 {execfile}
> 1 0.002 0.002 2.240 2.240 pyterm.py:30(<module>)
> 1 0.000 0.000 2.234 2.234 pyterm.py:189(main)
> 1 0.000 0.000 2.232 2.232 pyterm.py:42(__init__)
> 1 0.000 0.000 2.232 2.232 pyterm.py:141(_open_port)
> 1 0.000 0.000 2.214 2.214 serialutil.py:212(__init__)
> 1 0.000 0.000 2.214 2.214 ftdiext.py:110(open)
> 1 0.000 0.000 2.213 2.213 ftdi.py:250(usb_find_all)
> 1 0.000 0.000 2.213 2.213 ftdi.py:689(_enumerate)
> 31 0.000 0.000 2.194 0.071 _debug.py:47(do_trace)
> 3 0.001 0.000 2.187 0.729 core.py:734(find)
> 4 0.000 0.000 2.171 0.543 core.py:803(device_iter)
> 3 0.000 0.000 2.168 0.723
> libusb10.py:409(enumerate_devices)
> 3 2.168 0.723 2.168 0.723 libusb10.py:395(__init__)
> 1 0.000 0.000 0.025 0.025 util.py:221(get_string)
>
--
Best Regards,
Wander Lairson Costa
LCoN - Laboratório de Computação Natural - Natural Computing Laboratory
(http://www.mackenzie.com.br/lcon.html)
Programa de Pós-Graduação em Engenharia Elétrica (PPGEE)
Faculdade de Computação e Informática (FCI)
Universidade Presbiteriana Mackenzie - SP - Brazil
------------------------------------------------------------------------------
Create and publish websites with WebMatrix
Use the most popular FREE web apps or write code yourself;
WebMatrix provides all the features you need to develop and
publish your website. http://p.sf.net/sfu/ms-webmatrix-sf
_______________________________________________
pyusb-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/pyusb-users