mirror of
https://github.com/flipperdevices/flipperzero-firmware.git
synced 2025-12-12 04:41:26 +04:00
Furi: count ISR time. Cli: show ISR time in top. (#3751)
* Furi: count ISR time. Cli: show ISR time in top. * hal: interrupt: macros for interrupt accounting; split FURI_ALWAYS_STATIC_INLINE -> FURI_ALWAYS_INLINE static Co-authored-by: hedger <hedger@nanode.su> Co-authored-by: hedger <hedger@users.noreply.github.com>
This commit is contained in:
@@ -29,8 +29,8 @@ extern "C" {
|
||||
#define FURI_PACKED __attribute__((packed))
|
||||
#endif
|
||||
|
||||
#ifndef FURI_ALWAYS_STATIC_INLINE
|
||||
#define FURI_ALWAYS_STATIC_INLINE __attribute__((always_inline)) static inline
|
||||
#ifndef FURI_ALWAYS_INLINE
|
||||
#define FURI_ALWAYS_INLINE __attribute__((always_inline)) inline
|
||||
#endif
|
||||
|
||||
#ifndef FURI_IS_IRQ_MASKED
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
#include "thread_list.h"
|
||||
#include "check.h"
|
||||
|
||||
#include <furi_hal_interrupt.h>
|
||||
|
||||
#include <m-array.h>
|
||||
#include <m-dict.h>
|
||||
|
||||
@@ -23,6 +25,8 @@ struct FuriThreadList {
|
||||
FuriThreadListItemDict_t search;
|
||||
uint32_t runtime_previous;
|
||||
uint32_t runtime_current;
|
||||
uint32_t isr_previous;
|
||||
uint32_t isr_current;
|
||||
};
|
||||
|
||||
FuriThreadList* furi_thread_list_alloc(void) {
|
||||
@@ -85,7 +89,10 @@ void furi_thread_list_process(FuriThreadList* instance, uint32_t runtime, uint32
|
||||
instance->runtime_previous = instance->runtime_current;
|
||||
instance->runtime_current = runtime;
|
||||
|
||||
uint32_t runtime_counter = instance->runtime_current - instance->runtime_previous;
|
||||
instance->isr_previous = instance->isr_current;
|
||||
instance->isr_current = furi_hal_interrupt_get_time_in_isr_total();
|
||||
|
||||
const uint32_t runtime_counter = instance->runtime_current - instance->runtime_previous;
|
||||
|
||||
FuriThreadListItemArray_it_t it;
|
||||
FuriThreadListItemArray_it(it, instance->items);
|
||||
@@ -108,3 +115,10 @@ void furi_thread_list_process(FuriThreadList* instance, uint32_t runtime, uint32
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
float furi_thread_list_get_isr_time(FuriThreadList* instance) {
|
||||
const uint32_t runtime_counter = instance->runtime_current - instance->runtime_previous;
|
||||
const uint32_t isr_counter = instance->isr_current - instance->isr_previous;
|
||||
|
||||
return (float)isr_counter / (float)runtime_counter;
|
||||
}
|
||||
@@ -76,6 +76,14 @@ FuriThreadListItem* furi_thread_list_get_or_insert(FuriThreadList* instance, Fur
|
||||
*/
|
||||
void furi_thread_list_process(FuriThreadList* instance, uint32_t runtime, uint32_t tick);
|
||||
|
||||
/** Get percent of time spent in ISR
|
||||
*
|
||||
* @param instance The instance
|
||||
*
|
||||
* @return percent of time spent in ISR
|
||||
*/
|
||||
float furi_thread_list_get_isr_time(FuriThreadList* instance);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user