GCC Code Coverage Report


Directory: ./
File: firmware/util/peak_detect.h
Date: 2025-10-03 00:57:22
Coverage Exec Excl Total
Lines: 100.0% 12 0 12
Functions: 100.0% 2 0 2
Branches: 100.0% 8 0 8
Decisions: 100.0% 4 - 4

Line Branch Decision Exec Source
1 #pragma once
2
3 #include "rusefi_types.h"
4
5 /**
6 * Stores the recent peak value, preventing loss of intermittent peaks in a signal.
7 */
8 template <typename TValue, efidur_t TTimeoutPeriod>
9 class PeakDetect {
10 public:
11 453 TValue detect(TValue currentValue, efitick_t nowNt) {
12
4/4
PeakDetect<float, 5000000l>::detect(float, long):
✓ Branch 0 taken 440 times.
✓ Branch 1 taken 8 times.
PeakDetect<int, 100l>::detect(int, long):
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 2 times.
4/4
PeakDetect<float, 5000000l>::detect(float, long):
✓ Decision 'true' taken 12 times.
✓ Decision 'false' taken 436 times.
PeakDetect<int, 100l>::detect(int, long):
✓ Decision 'true' taken 3 times.
✓ Decision 'false' taken 2 times.
453 if ((nowNt > m_lastPeakTime + TTimeoutPeriod) || // if timed out
13
4/4
PeakDetect<float, 5000000l>::detect(float, long):
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 436 times.
PeakDetect<int, 100l>::detect(int, long):
✓ Branch 0 taken 1 time.
✓ Branch 1 taken 2 times.
443 (currentValue > m_peak)) { // or current is higher than the previous peak
14 // store new peak and time
15 15 m_peak = currentValue;
16 15 m_lastPeakTime = nowNt;
17 }
18
19 453 return m_peak;
20 }
21
22 private:
23 TValue m_peak = std::numeric_limits<TValue>::min();
24 efitick_t m_lastPeakTime = std::numeric_limits<efitick_t>::min();
25 };
26