3.2. Performance Optimization
3.2. 1. Introduction to Performance Optimization
Performance optimization is the process of improving the speed and responsiveness of an embedded system while maintaining its required functionality
Performance is especially important in systems that must respond quickly to external events.
Examples
Performance optimization may involve:
- Increasing processor speed.
- Reducing program execution time.
- Improving algorithms.
- Reducing unnecessary calculations.
- Using interrupts instead of continuous polling.
- Optimizing communication between devices.
- Using hardware peripherals instead of performing everything in software.
- Timers
- ADC
- PWM
- UART
- SPI
- I²C
- Faster response.
- Lower latency.
- Better real-time operation.
- Improved user experience.
- More efficient CPU utilization.
Example
Suppose an Arduino reads a temperature sensor every second:
void loop() {
delay(1000);
temperature = analogRead(A0);}
The delay(1000) forces the processor to wait for one second.
A better design can use a timer or millis() so that the processor can perform other tasks while waiting.
3.2. 2. Performance optimization techniques
1. Improve algorithms
A more efficient algorithm can perform the same task using fewer operations.
For example, searching through 1,000 values using an efficient search method can be much faster than checking every value unnecessarily
2. Use interrupts
Instead of continuously checking whether an event has occurred, the processor can be interrupted when the event happens.
3. Reduce unnecessary calculations
Calculations that do not need to be performed repeatedly should be calculated once and stored.
4. Use hardware peripherals
A microcontroller may have built-in:
Using these peripherals can reduce the amount of work performed by the CPU.
3.2. 3. Benefits of performance optimization


