search.noResults

search.searching

saml.title
dataCollection.invalidEmail
note.createNoteMessage

search.noResults

search.searching

orderForm.title

orderForm.productCode
orderForm.description
orderForm.quantity
orderForm.itemPrice
orderForm.price
orderForm.totalPrice
orderForm.deliveryDetails.billingAddress
orderForm.deliveryDetails.deliveryAddress
orderForm.noItems
EMBEDDED DEVICES


Evaluating the performance of different embedded algorithms in Python


Mohammed Billoo, founder of MAB Labs looks at how the Tracealyzer tool can be used to evaluate the performance of an algorithm written in different ways in Python


P


ython is becoming more common in embedded application development, particularly for machine learning frameworks that run at the edge of the network. However, this high-level general-purpose programming language abstracts away many details in the code that can impact the performance of an implementation in ways that developers may not be aware of.


Let’s take an obvious example: computing the Fibonacci sequence. There are at least two different ways to perform this, a recursive algorithm and a standard iterative algorithm, with greatly varying levels of performance. The performance of different implementations or algorithms can be assessed with a tool called Tracealyzer. This is a visual trace diagnostics tool from Percepio that gives embedded software developers insight into the code at runtime for easier debugging of system-level issues and helps them improve the design and performance of their software. Tracealyzer can be used side-by-side with traditional debuggers such as the open- source Eclipse tools and complements the detailed debugger view with several additional views on system level. This helps understand real-time issues where a classic debugger is not sufficient.


Combined with the LTTng open-source tracing package in a Linux operating system distribution, Tracealyzer can show the different levels of performance. This is independent of the processor, and a result of the chosen algorithm.


For the evaluation, each implementation of the Fibonacci sequence is performed in a single module: def recur_fibo(n): if n <=1 n: return n else:


return(recur_fibo(n-1) + recur_fibo(n-2)) def non_recur_fibo(n): result = [] a,b = 0,1


14 MARCH 2022 | ELECTRONICS TODAY while a < n:


result.append(a) a,b = b, a+b return result


There are separate Python source files that call the two functions above: import lttngust import logging import fib


def example(): logging.basicConfig()


logger = logging.getLogger(‘my-logger’) logger.info(‘Start’) fib.recur_fibo(10) logger.info(‘Stop’) logger.info(‘Start’)


Mohammed Billoo, Founder of MAB Labs, LLC


Figure 1: Fib Timeline


fib.non_recur_fibo(10) logger.info(‘Stop’)


if __name__ == ‘__main__’: example()


The following commands capture a trace in LTTng that can then be examined in Tracealyzer:


$> lttng create


$> lttng enable-event --kernel sched_switch $> lttng enable-event --python my-logger $> lttng start


$> python3 <example source file>.py $> lttng stop $> lttng destroy


Page 1  |  Page 2  |  Page 3  |  Page 4  |  Page 5  |  Page 6  |  Page 7  |  Page 8  |  Page 9  |  Page 10  |  Page 11  |  Page 12  |  Page 13  |  Page 14  |  Page 15  |  Page 16  |  Page 17  |  Page 18  |  Page 19  |  Page 20  |  Page 21  |  Page 22  |  Page 23  |  Page 24  |  Page 25  |  Page 26  |  Page 27  |  Page 28  |  Page 29  |  Page 30  |  Page 31  |  Page 32  |  Page 33  |  Page 34  |  Page 35  |  Page 36  |  Page 37  |  Page 38  |  Page 39  |  Page 40  |  Page 41  |  Page 42  |  Page 43  |  Page 44  |  Page 45  |  Page 46