Skip to content
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

Closed
wants to merge 1 commit into from

Conversation

vbalyasnyy
Copy link
Contributor

Signed-off-by: Vasilyy Balyasnyy v.balyasnyy@gmail.com

Fixes #192 .

Changes proposed in this pull request:

  • create fps widget;
  • calculate for frame count/render thread count/update and render widget count;

@lc-soft

@lc-soft
Copy link
Owner

lc-soft commented Feb 11, 2020

I'm rewriting the widget's update and layout system. Please wait for me to finish these changes before continuing.

@lc-soft
Copy link
Owner

lc-soft commented Feb 17, 2020

@vbalyasnyy
Please handle the conflict. maybe you need rebase this branch.

src/main.c Outdated Show resolved Hide resolved
@lc-soft lc-soft force-pushed the develop branch 2 times, most recently from 77d12d6 to 103544c Compare March 1, 2020 12:18
@lc-soft
Copy link
Owner

lc-soft commented Mar 22, 2020

Is there any news on this pull reuqest?

Signed-off-by: Vasilyy Balyasnyy <v.balyasnyy@gmail.com>
Copy link
Owner

@lc-soft lc-soft left a 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.* to fpsmeter.*
  • 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>
Copy link
Owner

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)
Copy link
Owner

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.

Copy link
Owner

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:

LCUI/src/main.c

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());
Copy link
Owner

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

@vbalyasnyy
Copy link
Contributor Author

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.

@vbalyasnyy vbalyasnyy closed this Apr 7, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add FPS meter
2 participants