update libprof calls to use local contexts

This commit is contained in:
Lephe 2020-10-13 21:32:22 +02:00
parent 36f3de29b8
commit ff15ac0d56
Signed by: Lephenixnoir
GPG Key ID: 1BBA026E13FC0495
6 changed files with 33 additions and 85 deletions

View File

@ -1,22 +0,0 @@
//---
// gintctl:prof-contexts - All contexts under which profiling is used
//---
#ifndef GINTCTL_PROF_CONTEXTS
#define GINTCTL_PROF_CONTEXTS
/* libprof requires its user to declare the number of execution contexts that
are being profiled. The number and IDs is maintained here */
enum {
PROFCTX_BASICS = 0,
PROFCTX_EMPTY,
PROFCTX_RENDER,
PROFCTX_INTSTRESS,
PROFCTX_RTCTMU,
/* Last element and bound checker */
PROFCTX_COUNT,
};
#endif /* GINTCTL_PROF_CONTEXTS */

View File

@ -8,7 +8,6 @@
#include <gintctl/gint.h>
#include <gintctl/util.h>
#include <gintctl/prof-contexts.h>
#include <libprof.h>
@ -215,17 +214,19 @@ static void draw_speed(rtc_time_t *time, uint32_t elapsed)
dupdate();
}
static prof_t prof;
static int speed_callback(int volatile *flag)
{
if(*flag == 0)
{
prof_enter(PROFCTX_RTCTMU);
prof_enter(prof);
*flag = 1;
return TIMER_CONTINUE;
}
else
{
prof_leave(PROFCTX_RTCTMU);
prof_leave(prof);
*flag = 2;
return TIMER_STOP;
}
@ -234,12 +235,12 @@ static int speed_callback(int volatile *flag)
static uint32_t test_speed(void)
{
int volatile flag = 0;
prof_clear(PROFCTX_RTCTMU);
prof = prof_make();
rtc_start_timer(RTC_16Hz, speed_callback, &flag);
while(flag != 2) sleep();
return prof_time(PROFCTX_RTCTMU);
return prof_time(prof);
}
//---

View File

@ -7,7 +7,6 @@
#include <gintctl/util.h>
#include <gintctl/menu.h>
#include <gintctl/prof-contexts.h>
#include <gintctl/gint.h>
#include <gintctl/perf.h>
@ -150,7 +149,7 @@ int main(GUNUSED int isappli, GUNUSED int optnum)
#endif
/* Start the profiling library */
prof_init(PROFCTX_COUNT);
prof_init();
#ifdef FX9860G
/* Use the Unicode font uf5x7 on fx-9860G */

View File

@ -4,7 +4,6 @@
#include <gintctl/perf.h>
#include <gintctl/util.h>
#include <gintctl/prof-contexts.h>
#include <libprof.h>
@ -21,20 +20,12 @@ uint32_t stress_interrupts(void)
{
int counter = 0;
int timer = timer_setup(TIMER_ANY, 1, stress_callback, &counter);
if(timer < 0) return 0;
if(timer >= 0)
{
prof_clear(PROFCTX_INTSTRESS);
prof_enter(PROFCTX_INTSTRESS);
return prof_exec({
timer_start(timer);
timer_wait(timer);
prof_leave(PROFCTX_INTSTRESS);
return prof_time(PROFCTX_INTSTRESS);
}
return 0;
});
}
/* gintctl_perf_interrupts(): Interrupt handling */

View File

@ -3,7 +3,6 @@
#include <gint/timer.h>
#include <gintctl/util.h>
#include <gintctl/prof-contexts.h>
#include <gintctl/perf.h>
#include <libprof.h>
@ -11,32 +10,21 @@
/* Waits some time and returns the libprof output in microseconds */
static uint32_t run_sleep(int us)
{
int ctx = PROFCTX_BASICS;
prof_clear(ctx);
prof_enter(ctx);
/* We can't use sleep_us() as we want a TMU */
volatile int flag = 0;
int timer = timer_setup(TIMER_TMU, us, timer_timeout, &flag);
if(timer >= 0)
{
if(timer < 0) return 0;
return prof_exec({
timer_start(timer);
timer_wait(timer);
}
prof_leave(ctx);
return prof_time(ctx);
});
}
/* Measure overhead of an empty context */
static uint32_t run_empty(void)
{
int ctx = PROFCTX_EMPTY;
prof_clear(ctx);
prof_enter(ctx);
prof_leave(ctx);
return prof_time(ctx);
return prof_exec();
}
/* gintctl_perf_libprof(): Test the libprof implementation */

View File

@ -3,7 +3,6 @@
#include <gint/std/stdio.h>
#include <gintctl/util.h>
#include <gintctl/prof-contexts.h>
#include <gintctl/perf.h>
#include <libprof.h>
@ -15,34 +14,26 @@ struct elapsed {
uint32_t fs_r5g6b5;
};
#define test(out, command) { \
prof_clear(PROFCTX_RENDER); \
prof_enter(PROFCTX_RENDER); \
command; \
prof_leave(PROFCTX_RENDER); \
out = prof_time(PROFCTX_RENDER); \
}
static void run_test(struct elapsed *time)
{
test(time->clear,
dclear(C_WHITE)
);
test(time->rect1,
drect(0, 0, 31, 31, C_WHITE)
);
test(time->rect2,
drect(1, 1, 32, 32, C_WHITE)
);
test(time->rect3,
drect(0, 0, _(127,395), _(63,223), C_WHITE)
);
time->clear = prof_exec({
dclear(C_WHITE);
});
time->rect1 = prof_exec({
drect(0, 0, 31, 31, C_WHITE);
});
time->rect2 = prof_exec({
drect(1, 1, 32, 32, C_WHITE);
});
time->rect3 = prof_exec({
drect(0, 0, _(127,395), _(63,223), C_WHITE);
});
#ifdef FXCG50
extern bopti_image_t img_swift;
test(time->fs_r5g6b5,
dimage(0, 0, &img_swift)
);
time->fs_r5g6b5 = prof_exec({
dimage(0, 0, &img_swift);
});
#endif
}
@ -112,9 +103,9 @@ void gintctl_perf_render(void)
/* Make the test here as we don't want to re-update the screen.
Because of triple buffering this would display an old
frame such as the application's main menu. */
test(time.update,
dupdate()
);
time.update = prof_exec({
dupdate();
});
key = getkey().key;
if(key == KEY_F1) run_test(&time), test = 1;