python - Pylibftdio device open too slow -


i have python script creates 3 bitbangdevices. has drastically different run times on pc , on coworker's pc. both have same versions of needed this.

example code:

from pylibftdi import bitbangdevice  def initialize(interface=0, dire=0xff):     device_id = "existing name"     if interface == 0:         device = [bitbangdevice(device_id=device_id, direction=dire, interface_select=x + 1) x in range(2)]         device.append(bitbangdevice(device_id=device_id, direction=0x0, interface_select=3))  if __name__ == '__main__':     initialize() 

system info:

user@user-lin:~/documents/script$ python -m pylibftdi.examples.info pylibftdi version     : 0.16.1.2 libftdi version       : libftdi_version(major=0, minor=0, micro=0, version_str='< 1.0 - no ftdi_get_library_version()', snapshot_str='unknown') libftdi library name  : libftdi.so.1 libusb version        : libusb_version(major=1, minor=0, micro=17, nano=10830, rc='', describe='http://libusbx.org') libusb library name   : libusb-1.0.so.0 python version        : 2.7.6 os platform           : linux-3.13.0-46-generic-x86_64-with-ubuntu-14.04-trusty 

profiling:

user@user-lin:~/documents/script$ sudo python -m cprofile -s tottime test.py           3904 function calls (3842 primitive calls) in 4.792 seconds     ordered by: internal time     ncalls  tottime  percall  cumtime  percall filename:lineno(function)         3    4.680    1.560    4.680    1.560 device.py:177(_open_device)        15    0.077    0.005    0.077    0.005 {method 'read' of 'file' objects}        15    0.018    0.001    0.018    0.001 {method 'search' of '_sre.sre_pattern' objects}        15    0.003    0.000    0.003    0.000 {posix.popen}         3    0.001    0.000    4.682    1.561 device.py:123(open)        12    0.001    0.000    0.001    0.000 device.py:372(ftdi_fn)         9    0.001    0.000    0.042    0.005 util.py:214(_findsoname_ldconfig)        11    0.001    0.000    0.001    0.000 {_ctypes.dlopen}        11    0.001    0.000    0.001    0.000 __init__.py:349(__init__)        15    0.001    0.000    0.001    0.000 re.py:204(escape)         1    0.001    0.001    0.001    0.001 __init__.py:4(<module>)         6    0.001    0.000    0.061    0.010 util.py:91(_findlib_gcc)         2    0.001    0.000    0.001    0.000 collections.py:288(namedtuple)         1    0.000    0.000    0.001    0.001 tempfile.py:18(<module>)         1    0.000    0.000    0.003    0.003 driver.py:9(<module>)       8/5    0.000    0.000    0.001    0.000 sre_parse.py:379(_parse)        14    0.000    0.000    0.000    0.000 __init__.py:382(__getitem__)        15    0.000    0.000    0.000    0.000 {method 'close' of 'file' objects}         1    0.000    0.000    0.000    0.000 hashlib.py:55(<module>)         1    0.000    0.000    0.000    0.000 collections.py:1(<module>)         1    0.000    0.000    0.004    0.004 __init__.py:14(<module>)         6    0.000    0.000    0.000    0.000 bitbang.py:115(direction)        15    0.000    0.000    0.002    0.000 re.py:226(_compile)      21/5    0.000    0.000    0.000    0.000 sre_compile.py:32(_compile)         3    0.000    0.000    0.000    0.000 device.py:223(baudrate)         7    0.000    0.000    0.000    0.000 {posix.open}         1    0.000    0.000    0.001    0.001 random.py:40(<module>)         1    0.000    0.000    0.000    0.000 io.py:34(<module>)         7    0.000    0.000    0.000    0.000 tempfile.py:135(next)         3    0.000    0.000    0.105    0.035 driver.py:96(_load_library)        57    0.000    0.000    0.002    0.000 {getattr}         9    0.000    0.000    0.103    0.011 util.py:252(find_library)       165    0.000    0.000    0.000    0.000 sre_parse.py:182(__next)         6    0.000    0.000    0.001    0.000 tempfile.py:230(_mkstemp_inner)        15    0.000    0.000    0.020    0.001 re.py:139(search)         6    0.000    0.000    0.105    0.017 driver.py:151(fdll)         1    0.000    0.000    0.001    0.001 util.py:4(<module>)         3    0.000    0.000    0.105    0.035 device.py:42(__init__)     34/18    0.000    0.000    0.000    0.000 sre_parse.py:140(getwidth)        12    0.000    0.000    0.000    0.000 device.py:391(__getattr__)         9    0.000    0.000    0.000    0.000 {hasattr}       113    0.000    0.000    0.000    0.000 sre_parse.py:130(__getitem__)       167    0.000    0.000    0.000    0.000 {isinstance}         1    0.000    0.000    0.000    0.000 {__import__}         7    0.000    0.000    0.000    0.000 {posix.unlink}        42    0.000    0.000    0.000    0.000 random.py:271(choice)         1    0.000    0.000    0.000    0.000 latin_1.py:8(<module>)         1    0.000    0.000    4.792    4.792 test.py:1(<module>)        10    0.000    0.000    0.001    0.000 __init__.py:432(__getattr__)         9    0.000    0.000    0.000    0.000 {method 'encode' of 'str' objects}        14    0.000    0.000    0.000    0.000 __init__.py:375(__getattr__)       150    0.000    0.000    0.000    0.000 sre_parse.py:201(get)         3    0.000    0.000    0.000    0.000 __init__.py:493(pyfunctype)         3    0.000    0.000    0.000    0.000 driver.py:169(libftdi_version)       533    0.000    0.000    0.000    0.000 {method 'append' of 'list' objects}         1    0.000    0.000    0.000    0.000 __init__.py:265(_reset_cache)         1    0.000    0.000    0.000    0.000 device.py:207(close)         3    0.000    0.000    4.683    1.561 bitbang.py:62(open)        65    0.000    0.000    0.000    0.000 {method 'startswith' of 'str' objects}         3    0.000    0.000    0.000    0.000 __init__.py:52(create_string_buffer)         1    0.000    0.000    4.788    4.788 test.py:3(initialize)         3    0.000    0.000    4.788    1.596 bitbang.py:34(__init__)         7    0.000    0.000    0.000    0.000 posixpath.py:336(normpath)         1    0.000    0.000    0.000    0.000 device.py:9(<module>)        83    0.000    0.000    0.000    0.000 {method 'get' of 'dict' objects}         8    0.000    0.000    0.000    0.000 {built-in method __new__ of type object @ 0x91d400}         5    0.000    0.000    0.001    0.000 sre_parse.py:675(parse)         5    0.000    0.000    0.002    0.000 sre_compile.py:493(compile)   529/516    0.000    0.000    0.000    0.000 {len}        12    0.000    0.000    0.000    0.000 {fcntl.fcntl}        13    0.000    0.000    0.000    0.000 sre_compile.py:207(_optimize_charset)         7    0.000    0.000    0.000    0.000 tempfile.py:124(rng)        13    0.000    0.000    0.000    0.000 sre_compile.py:178(_compile_charset)         3    0.000    0.000    0.000    0.000 __init__.py:78(cfunctype)         6    0.000    0.000    0.001    0.000 tempfile.py:274(mkstemp)        32    0.000    0.000    0.000    0.000 {_ctypes.byref}         1    0.000    0.000    0.000    0.000 _endian.py:4(<module>)         6    0.000    0.000    0.000    0.000 tempfile.py:48(_set_cloexec)         7    0.000    0.000    0.000    0.000 posixpath.py:68(join)        34    0.000    0.000    0.000    0.000 {method 'join' of 'str' objects}         5    0.000    0.000    0.000    0.000 sre_compile.py:359(_compile_info)         8    0.000    0.000    0.000    0.000 abc.py:148(__subclasscheck__)        12    0.000    0.000    0.000    0.000 device.py:389(ftdiforwarder)       105    0.000    0.000    0.000    0.000 sre_parse.py:138(append)        15    0.000    0.000    0.000    0.000 sre_parse.py:225(_class_escape)        14    0.000    0.000    0.000    0.000 __init__.py:147(_check_size)         1    0.000    0.000    0.000    0.000 tempfile.py:176(_get_default_tempdir)         9    0.000    0.000    0.000    0.000 {posix.uname}       8/5    0.000    0.000    0.001    0.000 sre_parse.py:301(_parse_sub)         3    0.000    0.000    0.000    0.000 {posix.urandom}        13    0.000    0.000    0.000    0.000 sre_compile.py:354(_simple)         3    0.000    0.000    0.000    0.000 <string>:8(__new__)         1    0.000    0.000    0.000    0.000 __init__.py:71(search_function)        14    0.000    0.000    0.000    0.000 sre_parse.py:257(_escape)         1    0.000    0.000    0.000    0.000 _base.py:9(<module>)         4    0.000    0.000    0.000    0.000 abc.py:86(__new__)         7    0.000    0.000    0.000    0.000 posixpath.py:365(abspath)        24    0.000    0.000    0.000    0.000 {method 'format' of 'str' objects}         5    0.000    0.000    0.000    0.000 sre_parse.py:178(__init__)         2    0.000    0.000    0.000    0.000 {_ctypes.pointer}        52    0.000    0.000    0.000    0.000 sre_parse.py:195(match)        10    0.000    0.000    0.000    0.000 sre_compile.py:472(isstring)         3    0.000    0.000    0.000    0.000 {function seed @ 0x7fe5245265f0}         7    0.000    0.000    0.000    0.000 {posix.close}        11    0.000    0.000    0.000    0.000 __init__.py:359(_funcptr)         5    0.000    0.000    0.001    0.000 sre_compile.py:478(_code)         5    0.000    0.000    0.000    0.000 {_sre.compile}         1    0.000    0.000    0.000    0.000 bitbang.py:9(<module>)        52    0.000    0.000    0.000    0.000 sre_parse.py:126(__len__)        42    0.000    0.000    0.000    0.000 {method 'random' of '_random.random' objects}         3    0.000    0.000    0.000    0.000 random.py:100(seed)         1    0.000    0.000    0.000    0.000 heapq.py:31(<module>)        27    0.000    0.000    0.000    0.000 {_struct.calcsize}       109    0.000    0.000    0.000    0.000 collections.py:329(<genexpr>)        21    0.000    0.000    0.000    0.000 sre_parse.py:90(__init__)        19    0.000    0.000    0.000    0.000 _weakrefset.py:58(__iter__)        10    0.000    0.000    0.000    0.000 {method 'split' of 'str' objects}         6    0.000    0.000    0.000    0.000 {_codecs.lookup}         1    0.000    0.000    0.000    0.000 <string>:1(<module>)         3    0.000    0.000    0.000    0.000 codecs.py:945(getincrementalencoder)        19    0.000    0.000    0.000    0.000 _weakrefset.py:36(__init__)         1    0.000    0.000    0.000    0.000 {_io.open}         5    0.000    0.000    0.000    0.000 sre_parse.py:67(__init__)         1    0.000    0.000    0.000    0.000 serial_device.py:9(<module>)        97    0.000    0.000    0.000    0.000 {ord}        13    0.000    0.000    0.000    0.000 {all}        42    0.000    0.000    0.000    0.000 {min}        12    0.000    0.000    0.000    0.000 {setattr}         6    0.000    0.000    0.000    0.000 tempfile.py:262(gettempdir)        16    0.000    0.000    0.000    0.000 _weakrefset.py:83(add)         7    0.000    0.000    0.000    0.000 posixpath.py:59(isabs)         1    0.000    0.000    0.000    0.000 util.py:9(<module>)         1    0.000    0.000    0.000    0.000 latin_1.py:41(getregentry)         3    0.000    0.000    0.000    0.000 codecs.py:162(__init__)         1    0.000    0.000    0.000    0.000 tempfile.py:148(_candidate_tempdir_list)         1    0.000    0.000    0.000    0.000 __init__.py:49(normalize_encoding)         1    0.000    0.000    0.000    0.000 {math.exp}         6    0.000    0.000    0.000    0.000 tempfile.py:216(_get_candidate_names)         1    0.000    0.000    0.000    0.000 __future__.py:48(<module>)         1    0.000    0.000    0.000    0.000 codecs.py:77(__new__)         1    0.000    0.000    0.000    0.000 device.py:37(device)        13    0.000    0.000    0.000    0.000 collections.py:353(<genexpr>)         3    0.000    0.000    0.000    0.000 sre_parse.py:72(opengroup)         1    0.000    0.000    0.000    0.000 <string>:1(libusb_version)         3    0.000    0.000    0.000    0.000 codecs.py:959(getincrementaldecoder)        13    0.000    0.000    0.000    0.000 sre_parse.py:134(__setitem__)         9    0.000    0.000    0.000    0.000 {method 'acquire' of 'thread.lock' objects}        13    0.000    0.000    0.000    0.000 collections.py:355(<genexpr>)     27/16    0.000    0.000    0.000    0.000 {issubclass}         1    0.000    0.000    0.000    0.000 collections.py:26(ordereddict)         1    0.000    0.000    0.000    0.000 device.py:118(__del__)         6    0.000    0.000    0.000    0.000 hashlib.py:94(__get_openssl_constructor)         7    0.000    0.000    0.000    0.000 {method 'endswith' of 'str' objects}        96    0.000    0.000    0.000    0.000 {method 'isalnum' of 'str' objects}         3    0.000    0.000    0.000    0.000 bitbang.py:107(direction)         8    0.000    0.000    0.000    0.000 abc.py:105(register)         9    0.000    0.000    0.000    0.000 {method 'release' of 'thread.lock' objects}         2    0.000    0.000    0.000    0.000 {repr}         7    0.000    0.000    0.000    0.000 {posix.getpid}         6    0.000    0.000    0.000    0.000 device.py:419(closed)         6    0.000    0.000    0.000    0.000 util.py:133(_get_soname)         8    0.000    0.000    0.000    0.000 _weakrefset.py:20(__enter__)         9    0.000    0.000    0.000    0.000 {method 'items' of 'dict' objects}         8    0.000    0.000    0.000    0.000 _weakrefset.py:52(_commit_removals)         8    0.000    0.000    0.000    0.000 _weakrefset.py:26(__exit__)         2    0.000    0.000    0.000    0.000 tempfile.py:120(__init__)         1    0.000    0.000    0.000    0.000 random.py:72(random)         1    0.000    0.000    0.000    0.000 <string>:1(libftdi_version)         6    0.000    0.000    0.000    0.000 {method 'setter' of 'property' objects}         3    0.000    0.000    0.000    0.000 sre_parse.py:83(closegroup)        38    0.000    0.000    0.000    0.000 {_ctypes.sizeof}         2    0.000    0.000    0.000    0.000 {math.log}         8    0.000    0.000    0.000    0.000 posixpath.py:51(normcase)         1    0.000    0.000    0.000    0.000 keyword.py:11(<module>)         1    0.000    0.000    0.000    0.000 tempfile.py:501(spooledtemporaryfile)         1    0.000    0.000    0.000    0.000 tempfile.py:108(_randomnamesequence)         3    0.000    0.000    0.000    0.000 os.py:510(getenv)         1    0.000    0.000    0.000    0.000 bitbang.py:21(bitbangdevice)         9    0.000    0.000    0.000    0.000 _weakrefset.py:70(__contains__)         3    0.000    0.000    0.000    0.000 {binascii.hexlify}         3    0.000    0.000    0.000    0.000 driver.py:87(__init__)         4    0.000    0.000    0.000    0.000 {method 'replace' of 'str' objects}         3    0.000    0.000    0.000    0.000 {method 'group' of '_sre.sre_match' objects}         8    0.000    0.000    0.000    0.000 _weakrefset.py:16(__init__)         1    0.000    0.000    0.000    0.000 latin_1.py:13(codec)         2    0.000    0.000    0.000    0.000 {map}         3    0.000    0.000    0.000    0.000 {method 'remove' of 'list' objects}         1    0.000    0.000    0.000    0.000 serial_device.py:19(serialdevice)         1    0.000    0.000    0.000    0.000 __init__.py:332(cdll)        13    0.000    0.000    0.000    0.000 {method '__contains__' of 'frozenset' objects}         1    0.000    0.000    0.000    0.000 {math.sqrt}         1    0.000    0.000    0.000    0.000 collections.py:387(counter)         3    0.000    0.000    0.000    0.000 random.py:91(__init__)         1    0.000    0.000    0.000    0.000 driver.py:75(driver)        35    0.000    0.000    0.000    0.000 {method 'add' of 'set' objects}         1    0.000    0.000    0.000    0.000 driver.py:22(libusb_version_struct)         1    0.000    0.000    0.000    0.000 {_ctypes.set_conversion_mode}         1    0.000    0.000    0.000    0.000 {_hashlib.openssl_md5}         1    0.000    0.000    0.000    0.000 device.py:31(ftdi_context_partial)         1    0.000    0.000    0.000    0.000 {method 'write' of '_io.bufferedwriter' objects}         3    0.000    0.000    0.000    0.000 __init__.py:104(cfunctiontype)         1    0.000    0.000    0.000    0.000 tempfile.py:372(_temporaryfilewrapper)         3    0.000    0.000    0.000    0.000 __init__.py:494(cfunctiontype)         1    0.000    0.000    0.000    0.000 __init__.py:238(c_char)         1    0.000    0.000    0.000    0.000 random.py:800(systemrandom)        16    0.000    0.000    0.000    0.000 sre_compile.py:24(_identityfunction)         1    0.000    0.000    0.000    0.000 {method 'disable' of '_lsprof.profiler' objects}         1    0.000    0.000    0.000    0.000 __init__.py:243(c_char_p)         1    0.000    0.000    0.000    0.000 {_hashlib.openssl_sha384}         1    0.000    0.000    0.000    0.000 random.py:650(wichmannhill)         1    0.000    0.000    0.000    0.000 latin_1.py:20(incrementalencoder)         1    0.000    0.000    0.000    0.000 latin_1.py:24(incrementaldecoder)         1    0.000    0.000    0.000    0.000 {_hashlib.openssl_sha224}         1    0.000    0.000    0.000    0.000 util.py:19(bus)         1    0.000    0.000    0.000    0.000 __future__.py:74(_feature)         3    0.000    0.000    0.000    0.000 codecs.py:235(__init__)         1    0.000    0.000    0.000    0.000 __init__.py:159(py_object)         3    0.000    0.000    0.000    0.000 userdict.py:70(__contains__)         1    0.000    0.000    0.000    0.000 io.py:69(iobase)         4    0.000    0.000    0.000    0.000 abc.py:89(<genexpr>)         8    0.000    0.000    0.000    0.000 {method '__subclasses__' of 'type' objects}         1    0.000    0.000    0.000    0.000 latin_1.py:34(streamconverter)         1    0.000    0.000    0.000    0.000 io.py:72(rawiobase)         1    0.000    0.000    0.000    0.000 {posix.getcwd}         1    0.000    0.000    0.000    0.000 __init__.py:428(libraryloader)         3    0.000    0.000    0.000    0.000 userdict.py:58(get)         1    0.000    0.000    0.000    0.000 __init__.py:388(pydll)         1    0.000    0.000    0.000    0.000 __init__.py:193(c_uint)         6    0.000    0.000    0.000    0.000 {method 'pop' of 'dict' objects}         3    0.000    0.000    0.000    0.000 {thread.allocate_lock}         1    0.000    0.000    0.000    0.000 driver.py:39(ftdi_version_info)         1    0.000    0.000    0.000    0.000 __init__.py:201(c_double)         1    0.000    0.000    0.000    0.000 driver.py:34(ftdi_device_list)         2    0.000    0.000    0.000    0.000 {sys._getframe}         1    0.000    0.000    0.000    0.000 __init__.py:189(c_int)         1    0.000    0.000    0.000    0.000 {method 'extend' of 'list' objects}         1    0.000    0.000    0.000    0.000 {_hashlib.openssl_sha1}         1    0.000    0.000    0.000    0.000 _base.py:17(ftdierror)         1    0.000    0.000    0.000    0.000 io.py:78(textiobase)         1    0.000    0.000    0.000    0.000 __init__.py:291(c_wchar_p)         6    0.000    0.000    0.000    0.000 {globals}         2    0.000    0.000    0.000    0.000 {method 'clear' of 'dict' objects}         1    0.000    0.000    0.000    0.000 __init__.py:260(c_bool)         1    0.000    0.000    0.000    0.000 _endian.py:26(_swapped_meta)         1    0.000    0.000    0.000    0.000 _endian.py:49(bigendianstructure)         1    0.000    0.000    0.000    0.000 __init__.py:172(c_ushort)         1    0.000    0.000    0.000    0.000 __init__.py:205(c_longdouble)         1    0.000    0.000    0.000    0.000 __init__.py:255(c_void_p)         8    0.000    0.000    0.000    0.000 {method '__subclasshook__' of 'object' objects}         1    0.000    0.000    0.000    0.000 __init__.py:176(c_long)         1    0.000    0.000    0.000    0.000 __init__.py:233(c_byte)        13    0.000    0.000    0.000    0.000 {method 'isdigit' of 'str' objects}         1    0.000    0.000    0.000    0.000 {_hashlib.openssl_sha256}         1    0.000    0.000    0.000    0.000 latin_1.py:31(streamreader)         1    0.000    0.000    0.000    0.000 {_hashlib.openssl_sha512}         1    0.000    0.000    0.000    0.000 _base.py:21(librarymissingerror)         1    0.000    0.000    0.000    0.000 __init__.py:197(c_float)         1    0.000    0.000    0.000    0.000 latin_1.py:28(streamwriter)         1    0.000    0.000    0.000    0.000 __init__.py:180(c_ulong)         1    0.000    0.000    0.000    0.000 {method 'translate' of 'str' objects}         1    0.000    0.000    0.000    0.000 __init__.py:294(c_wchar)         1    0.000    0.000    0.000    0.000 {range}         2    0.000    0.000    0.000    0.000 __init__.py:429(__init__)         1    0.000    0.000    0.000    0.000 io.py:75(bufferediobase)         1    0.000    0.000    0.000    0.000 __init__.py:168(c_short)         1    0.000    0.000    0.000    0.000 __init__.py:226(c_ubyte)         8    0.000    0.000    0.000    0.000 {method 'remove' of 'set' objects}         7    0.000    0.000    0.000    0.000 __future__.py:75(__init__) 

could think reason difference in running times?


Comments

Popular posts from this blog

Is there a better way to structure post methods in Class Based Views -

performance - Why is XCHG reg, reg a 3 micro-op instruction on modern Intel architectures? -

jquery - Responsive Navbar with Sub Navbar -