gintctl/src/perf/interrupt.c

82 lines
1.4 KiB
C
Raw Normal View History

2020-07-19 22:55:58 +02:00
#include <gint/display.h>
#include <gint/keyboard.h>
#include <gint/timer.h>
#include <gintctl/perf.h>
#include <gintctl/util.h>
#include <libprof.h>
#define STRESS_LIMIT 1000
int stress_callback(int *counter)
{
(*counter)++;
if(*counter >= STRESS_LIMIT) return TIMER_STOP;
return TIMER_CONTINUE;
}
uint32_t stress_interrupts(void)
{
int counter = 0;
2021-04-27 14:57:27 +02:00
int timer = timer_configure(TIMER_ANY, 1,
GINT_CALL(stress_callback, &counter));
if(timer < 0) return 0;
2020-07-19 22:55:58 +02:00
return prof_exec({
2020-07-19 22:55:58 +02:00
timer_start(timer);
timer_wait(timer);
});
2020-07-19 22:55:58 +02:00
}
/* gintctl_perf_interrupts(): Interrupt handling */
void gintctl_perf_interrupts(void)
{
uint32_t time_spent = stress_interrupts();
int rate = 0;
int key = 0;
if(time_spent > 0)
{
rate = 1000000ull * STRESS_LIMIT / time_spent;
}
while(key != KEY_EXIT)
{
dclear(C_WHITE);
#ifdef FX9860G
row_title("Interrupt stress");
if(time_spent == 0)
{
row_print(3, 1, "Not tested");
}
else
{
row_print(3, 1, "Count: %d", STRESS_LIMIT);
row_print(4, 1, "Time: %d us", time_spent);
row_print(5, 1, "Rate: %d int/s", rate);
}
#endif
#ifdef FXCG50
row_title("Interrupt handling stress test");
if(time_spent == 0)
{
row_print(1, 1, "Not tested");
}
else
{
row_print(1, 1, "%d interrupts handled in %d us",
STRESS_LIMIT, time_spent);
row_print(2, 1, "Rate is %d int/s", rate);
}
#endif
dupdate();
key = getkey().key;
}
}