From 65d3a194996fc393a52a53b555182cf45fb4889d Mon Sep 17 00:00:00 2001 From: yellows8 Date: Mon, 26 Feb 2018 18:56:52 -0500 Subject: [PATCH] Added optional PERF_LOG* defines. --- common/menu.c | 13 +++++++++++++ nx_main/main.c | 26 ++++++++++++++++++++++++++ 2 files changed, 39 insertions(+) diff --git a/common/menu.c b/common/menu.c index bae6800..9411c88 100644 --- a/common/menu.c +++ b/common/menu.c @@ -340,6 +340,19 @@ void menuLoop() { DrawText(interuiregular14, 180, 46, themeCurrent.textColor, "v2.0.0"); DrawTextTruncate(interuiregular18, 40, 720 - 47, themeCurrent.textColor, menu->dirname, 918, "..."); + #ifdef PERF_LOG_DRAW//Seperate from the PERF_LOG define since this might affect perf. + extern u64 g_tickdiff_vsync; + extern u64 g_tickdiff_frame; + + char tmpstr[64]; + + snprintf(tmpstr, sizeof(tmpstr)-1, "%lu", g_tickdiff_vsync); + DrawText(interuiregular14, 180 + 256, 46, themeCurrent.textColor, tmpstr); + + snprintf(tmpstr, sizeof(tmpstr)-1, "%lu", g_tickdiff_frame); + DrawText(interuiregular14, 180 + 256, 46 + 16, themeCurrent.textColor, tmpstr); + #endif + //drawTime(); if (menu->nEntries==0) diff --git a/nx_main/main.c b/nx_main/main.c index 0eb9570..d805b41 100644 --- a/nx_main/main.c +++ b/nx_main/main.c @@ -7,8 +7,17 @@ uint8_t* g_framebuf; u32 g_framebuf_width; +#ifdef PERF_LOG +u64 g_tickdiff_vsync=0; +u64 g_tickdiff_frame=0; +#endif + int main(int argc, char **argv) { + #ifdef PERF_LOG + u64 start_tick=0; + #endif + gfxInitDefault(); appletSetScreenShotPermission(1); @@ -21,8 +30,20 @@ int main(int argc, char **argv) launchInit(); + #ifdef PERF_LOG + gfxWaitForVsync(); + + start_tick = svcGetSystemTick(); + gfxWaitForVsync(); + g_tickdiff_vsync = svcGetSystemTick() - start_tick; + #endif + while (appletMainLoop()) { + #ifdef PERF_LOG + start_tick = svcGetSystemTick(); + #endif + //Scan all the inputs. This should be done once for each frame hidScanInput(); @@ -32,6 +53,11 @@ int main(int argc, char **argv) menuLoop(); gfxFlushBuffers(); + + #ifdef PERF_LOG + g_tickdiff_frame = svcGetSystemTick() - start_tick; + #endif + gfxSwapBuffers(); gfxWaitForVsync(); }