[client] app: collect render and frame timing information

This commit is contained in:
Geoffrey McRae 2021-07-09 01:53:49 +10:00
parent 94ae9a95d7
commit c3bc5fb0ff
2 changed files with 25 additions and 4 deletions

View File

@ -149,11 +149,15 @@ static int renderThread(void * unused)
}
LG_UNLOCK(g_state.lgrLock);
const uint64_t t = nanotime();
const uint64_t delta = t - g_state.lastRenderTime;
g_state.lastRenderTime = t;
const float fdelta = (float)delta / 1000000.0f;
ringbuffer_push(g_state.renderTimings, &fdelta);
if (g_state.showFPS)
{
const uint64_t t = nanotime();
g_state.renderTime += t - g_state.lastFrameTime;
g_state.lastFrameTime = t;
g_state.renderTime += delta;
++g_state.renderCount;
if (g_state.renderTime > 1e9)
@ -594,6 +598,12 @@ int main_frameThread(void * unused)
g_state.autoIdleInhibitState = frame->blockScreensaver;
}
const uint64_t t = nanotime();
const uint64_t delta = t - g_state.lastFrameTime;
g_state.lastFrameTime = t;
const float fdelta = (float)delta / 1000000.0f;
ringbuffer_push(g_state.frameTimings, &fdelta);
atomic_fetch_add_explicit(&g_state.frameCount, 1, memory_order_relaxed);
lgSignalEvent(e_frame);
lgmpClientMessageDone(queue);
@ -697,6 +707,10 @@ static int lg_run(void)
ImFontAtlas_GetTexDataAsRGBA32(g_state.io->Fonts, &text_pixels,
&text_w, &text_h, NULL);
// initialize metrics ringbuffers
g_state.renderTimings = ringbuffer_new(256, sizeof(float));
g_state.frameTimings = ringbuffer_new(256, sizeof(float));
// search for the best displayserver ops to use
for(int i = 0; i < LG_DISPLAYSERVER_COUNT; ++i)
if (LG_DisplayServers[i]->probe())
@ -1064,6 +1078,10 @@ static void lg_shutdown(void)
ivshmemClose(&g_state.shm);
// free metrics ringbuffers
ringbuffer_free(&g_state.renderTimings);
ringbuffer_free(&g_state.frameTimings );
igDestroyContext(NULL);
}

View File

@ -29,6 +29,7 @@
#include "common/types.h"
#include "common/ivshmem.h"
#include "common/locking.h"
#include "common/ringbuffer.h"
#include "spice/spice.h"
#include <lgmp/client.h>
@ -96,9 +97,11 @@ struct AppState
atomic_uint_least64_t frameTime;
uint64_t lastFrameTime;
uint64_t renderTime;
uint64_t lastRenderTime;
atomic_uint_least64_t frameCount;
uint64_t renderCount;
RingBuffer renderTimings;
RingBuffer frameTimings;
uint64_t resizeTimeout;
bool resizeDone;