executor runtime stats

This commit is contained in:
rusefi 2017-06-07 22:55:05 -04:00
parent 7ac05a804a
commit 1ae91b98d0
3 changed files with 29 additions and 4 deletions

View File

@ -72,6 +72,7 @@ extern bool main_loop_started;
#include "flash_main.h"
#include "max31855.h"
#include "vehicle_speed.h"
#include "SingleTimerExecutor.h"
#endif
static bool subscription[(int) RO_LAST_ELEMENT];
@ -672,6 +673,10 @@ void updateTunerStudioState(TunerStudioOutputChannels *tsOutputChannels DECLARE_
int rpm = 0;
#endif
#if EFI_PROD_CODE || defined(__DOXYGEN__)
executorStatistics();
#endif
float tps = getTPS(PASS_ENGINE_PARAMETER_SIGNATURE);
float coolant = getCoolantTemperature(PASS_ENGINE_PARAMETER_SIGNATURE);
float intake = getIntakeAirTemperature(PASS_ENGINE_PARAMETER_SIGNATURE);

View File

@ -17,8 +17,9 @@
#include "efitime.h"
#include "efilib2.h"
#if EFI_PROD_CODE
#if EFI_PROD_CODE || defined(__DOXYGEN__)
#include "microsecond_timer.h"
#include "tunerstudio_configuration.h"
#endif
#if (EFI_SIGNAL_EXECUTOR_ONE_TIMER && EFI_PROD_CODE )|| defined(__DOXYGEN__)
@ -52,6 +53,7 @@ static void executorCallback(void *arg) {
Executor::Executor() {
reentrantFlag = false;
doExecuteCounter = scheduleCounter = timerCallbackCounter = 0;
/**
* todo: a good comment
*/
@ -60,6 +62,7 @@ Executor::Executor() {
void Executor::scheduleByTime(scheduling_s *scheduling, efitimeus_t timeUs, schfunc_t callback,
void *param) {
scheduleCounter++;
// if (delayUs < 0) {
// firmwareError(OBD_PCM_Processor_Fault, "Negative delayUs %s: %d", prefix, delayUs);
// return;
@ -85,6 +88,7 @@ void Executor::scheduleByTime(scheduling_s *scheduling, efitimeus_t timeUs, schf
}
void Executor::onTimerCallback() {
timerCallbackCounter++;
bool alreadyLocked = lockAnyContext();
doExecute();
scheduleTimerCallback();
@ -96,6 +100,7 @@ void Executor::onTimerCallback() {
* this private method is executed under lock
*/
void Executor::doExecute() {
doExecuteCounter++;
/**
* Let's execute actions we should execute at this point.
* reentrantFlag takes care of the use case where the actions we are executing are scheduling
@ -162,10 +167,21 @@ void scheduleByTime(scheduling_s *scheduling, efitimeus_t time, schfunc_t callba
void initSignalExecutorImpl(void) {
globalTimerCallback = executorCallback;
#if EFI_PROD_CODE
initMicrosecondTimer();
#endif /* EFI_PROD_CODE */
}
#endif
extern TunerStudioOutputChannels tsOutputChannels;
#include "engine.h"
EXTERN_ENGINE;
void executorStatistics() {
if (engineConfiguration->debugMode == DM_18) {
tsOutputChannels.debugIntField1 = instance.timerCallbackCounter;
tsOutputChannels.debugIntField2 = instance.doExecuteCounter;
tsOutputChannels.debugIntField3 = instance.scheduleCounter;
}
}
#endif /* EFI_SIGNAL_EXECUTOR_ONE_TIMER */

View File

@ -16,6 +16,9 @@ public:
Executor();
void scheduleByTime(scheduling_s *scheduling, efitimeus_t timeUs, schfunc_t callback, void *param);
void onTimerCallback();
int timerCallbackCounter;
int scheduleCounter;
int doExecuteCounter;
private:
EventQueue queue;
bool reentrantFlag;
@ -24,5 +27,6 @@ private:
};
void initSignalExecutorImpl(void);
void executorStatistics();
#endif /* SINGLETIMEREXECUTOR_H_ */