hexWithoutQuotes function is always evaluated even when debug is not enabled especially for common write and _writeRead functions:
|
self._debugprint("Response: " + hexWithoutQuotes(result)) |
|
self._debugprint("Sent: " + hexWithoutQuotes(wb)) |
In a program that uses many i2c read/writes, hexWithoutQuotes + hex function can take over 2% of the runtime as shown in the following cProfile results:
Ordered by: internal time
ncalls tottime percall cumtime percall filename:lineno(function)
15647 103.943 0.007 104.009 0.007 LabJackPython.py:374(_readFromExodriver)
15647 5.683 0.000 5.770 0.000 LabJackPython.py:248(_writeToExodriver)
56/51 3.911 0.070 3.911 0.077 {method 'acquire' of '_thread.lock' objects}
9 1.826 0.203 1.826 0.203 {built-in method time.sleep}
31287 1.534 0.000 2.471 0.000 LabJackPython.py:3182(hexWithoutQuotes)
1182380 0.628 0.000 0.628 0.000 {built-in method builtins.hex}
15640 0.367 0.000 114.058 0.007 LabJackPython.py:564(_writeRead)
Suggest adding a simple call guard to avoid hexWithoutQuotes getting evaluated when debug it not enable. For example:
if self.debug:
self._debugprint("Response: " + hexWithoutQuotes(result))
hexWithoutQuotesfunction is always evaluated even when debug is not enabled especially for common write and _writeRead functions:LabJackPython/src/LabJackPython.py
Line 570 in a2f13eb
LabJackPython/src/LabJackPython.py
Line 317 in a2f13eb
In a program that uses many i2c read/writes, hexWithoutQuotes + hex function can take over 2% of the runtime as shown in the following cProfile results:
Suggest adding a simple call guard to avoid
hexWithoutQuotesgetting evaluated when debug it not enable. For example: