-
-
Notifications
You must be signed in to change notification settings - Fork 357
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(profiling): add fps meter (#192) #196
Conversation
I'm rewriting the widget's update and layout system. Please wait for me to finish these changes before continuing. |
95dd09b
to
cf1208e
Compare
@vbalyasnyy |
77d12d6
to
103544c
Compare
Is there any news on this pull reuqest? |
Signed-off-by: Vasilyy Balyasnyy <v.balyasnyy@gmail.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Changes needed:
- Rename
widget_fpsmeter.*
tofpsmeter.*
- Let FpsMeter provide only one public interface:
void LCUI_EnableFpsMeter(LCUI_BOOL enabled);
- Other modules should not call FpsMeter functions
- Update main.c file to add the following public interfaces:
void LCUI_GetProfile(LCUI_Profile profile); void LCUI_EnableProfile(LCUI_BOOL enable);
-
LCUI_EnableProfile()
is called when FpsMeter is enabled
@@ -35,6 +35,7 @@ | |||
#include <LCUI_Build.h> | |||
#include <LCUI/LCUI.h> | |||
#include <LCUI/gui/widget.h> | |||
#include <LCUI/gui/widget_fpsmeter.h> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please rename file widget_fpsmeter.*
to fpsmeter.*
, Because it is not part of the widget system
} | ||
} | ||
|
||
void LCUI_FpsMeter_RenderThreadCount(int count) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should make this module provide less public interface, I think only one interface is enough:
void LCUI_EnableFpsMeter(LCUI_BOOL enabled);
If FpsMeter is enabled, we can create a timer to get profile data every second andrenders to FpsMeter.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can call the function here to get the data:
Lines 113 to 156 in 7c9a6d1
#ifdef DEBUG | |
static void LCUIProfile_Init(LCUI_Profile profile) | |
{ | |
memset(profile, 0, sizeof(LCUI_ProfileRec)); | |
profile->start_time = clock(); | |
} | |
static void LCUIProfile_Print(LCUI_Profile profile) | |
{ | |
unsigned i; | |
LCUI_FrameProfile frame; | |
Logger_Debug("\nframes_count: %zu, time: %ld\n", profile->frames_count, | |
profile->end_time - profile->start_time); | |
for (i = 0; i < profile->frames_count; ++i) { | |
frame = &profile->frames[i]; | |
Logger_Debug("=== frame [%u/%u] ===\n", i + 1, | |
profile->frames_count); | |
Logger_Debug("timers.count: %zu\ntimers.time: %ldms\n", | |
frame->timers_count, frame->timers_time); | |
Logger_Debug("events.count: %zu\nevents.time: %ldms\n", | |
frame->events_count, frame->events_time); | |
Logger_Debug("widget_tasks.time: %ldms\n" | |
"widget_tasks.update_count: %u\n" | |
"widget_tasks.refresh_count: %u\n" | |
"widget_tasks.layout_count: %u\n" | |
"widget_tasks.user_task_count: %u\n" | |
"widget_tasks.destroy_count: %u\n" | |
"widget_tasks.destroy_time: %ldms\n", | |
frame->widget_tasks.time, | |
frame->widget_tasks.update_count, | |
frame->widget_tasks.refresh_count, | |
frame->widget_tasks.layout_count, | |
frame->widget_tasks.user_task_count, | |
frame->widget_tasks.destroy_count, | |
frame->widget_tasks.destroy_time); | |
Logger_Debug("render: %zu, %ldms, %ldms\n", frame->render_count, | |
frame->render_time, frame->present_time); | |
} | |
} | |
static LCUI_FrameProfile LCUIProfile_BeginFrame(LCUI_Profile profile) |
But I suggest you modify it to provide the following public interfaces:
void LCUI_GetProfile(LCUI_Profile profile);
void LCUI_EnableProfile(LCUI_BOOL enable);
@@ -337,6 +338,9 @@ static size_t LCUIDisplay_RenderSurface(SurfaceRecord record) | |||
for (i = 0; i < (int)rects.length; ++i) { | |||
count += LCUIDisplay_RenderSurfaceRect(record, | |||
rect_array[i]); | |||
#ifdef USE_OPENMP | |||
LCUI_FpsMeter_RenderThreadCount(omp_get_num_threads()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Other modules should not call FpsMeter functions, Because the low-level function code should not depend on the upper-level function code
Hi @lc-soft sorry for waiting for me i think this patch is ugly... there are needs some refactoring of profiling features before implement setting and fps meters. I do not want to blocking other developers, if i have some more time in nearest future, i 'l do it. |
Signed-off-by: Vasilyy Balyasnyy v.balyasnyy@gmail.com
Fixes #192 .
Changes proposed in this pull request:
@lc-soft