add an interrupt stress test

This commit is contained in:
Lephe 2020-07-19 22:55:58 +02:00
parent dd43d25a77
commit b0c3245423
Signed by: Lephenixnoir
GPG Key ID: 1BBA026E13FC0495
4 changed files with 94 additions and 0 deletions

View File

@ -8,6 +8,9 @@
/* gintctl_perf_libprof(): Basic libprof tests using timers */
void gintctl_perf_libprof(void);
/* gintctl_perf_interrupts(): Interrupt handling */
void gintctl_perf_interrupts(void);
/* gintctl_perf_render(): Profile the display primitives */
void gintctl_perf_render(void);

View File

@ -12,6 +12,7 @@ enum {
PROFCTX_BASICS = 0,
PROFCTX_EMPTY,
PROFCTX_RENDER,
PROFCTX_INTSTRESS,
/* Last element and bound checker */
PROFCTX_COUNT,

View File

@ -61,6 +61,7 @@ struct menu menu_perf = {
_("Performance", "Performance benchmarks"), .entries = {
{ "libprof basics", gintctl_perf_libprof },
{ "Interrupt stress", gintctl_perf_interrupts },
{ "Rendering functions", gintctl_perf_render },
/* TODO: Comparison with MonochromeLib */

89
src/perf/interrupt.c Normal file
View File

@ -0,0 +1,89 @@
#include <gint/display.h>
#include <gint/keyboard.h>
#include <gint/timer.h>
#include <gintctl/perf.h>
#include <gintctl/util.h>
#include <gintctl/prof-contexts.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;
int timer = timer_setup(TIMER_ANY, 1, stress_callback, &counter);
if(timer >= 0)
{
prof_clear(PROFCTX_INTSTRESS);
prof_enter(PROFCTX_INTSTRESS);
timer_start(timer);
timer_wait(timer);
prof_leave(PROFCTX_INTSTRESS);
return prof_time(PROFCTX_INTSTRESS);
}
return 0;
}
/* 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;
}
}