Add performance counters

pull/58/head
Andri Yngvason 2020-07-25 22:17:13 +00:00
parent 85fca04e27
commit c8ba15c455
1 changed files with 38 additions and 1 deletions

View File

@ -91,6 +91,9 @@ struct wayvnc {
struct pixman_region16 current_damage; struct pixman_region16 current_damage;
const char* kb_layout; const char* kb_layout;
uint32_t n_frames_captured;
uint32_t n_frames_rendered;
}; };
void wayvnc_exit(struct wayvnc* self); void wayvnc_exit(struct wayvnc* self);
@ -482,6 +485,8 @@ static void on_render(struct nvnc_display* display, struct nvnc_fb* fb)
if (!self->screencopy.back) if (!self->screencopy.back)
return; return;
self->n_frames_rendered++;
DTRACE_PROBE(wayvnc, render_start); DTRACE_PROBE(wayvnc, render_start);
enum wl_output_transform transform = self->selected_output->transform; enum wl_output_transform transform = self->selected_output->transform;
@ -521,6 +526,8 @@ void wayvnc_process_frame(struct wayvnc* self)
uint32_t height = output_get_transformed_height(self->selected_output); uint32_t height = output_get_transformed_height(self->selected_output);
uint32_t format = self->screencopy.back->format; uint32_t format = self->screencopy.back->format;
self->n_frames_captured++;
if ((int)self->selected_output->width != self->screencopy.back->width if ((int)self->selected_output->width != self->screencopy.back->width
|| (int)self->selected_output->height != self->screencopy.back->height) { || (int)self->selected_output->height != self->screencopy.back->height) {
log_debug("Frame dimensions don't match output. Recapturing frame...\n"); log_debug("Frame dimensions don't match output. Recapturing frame...\n");
@ -647,6 +654,28 @@ int check_cfg_sanity(struct cfg* cfg)
return 0; return 0;
} }
static void on_perf_tick(void* obj)
{
struct wayvnc* self = aml_get_userdata(obj);
printf("Frames captured: %"PRIu32", rendered: %"PRIu32"\n",
self->n_frames_captured, self->n_frames_rendered);
self->n_frames_captured = 0;
self->n_frames_rendered = 0;
}
static void start_performance_ticker(struct wayvnc* self)
{
struct aml_ticker* ticker = aml_ticker_new(1000, on_perf_tick, self,
NULL);
if (!ticker)
return;
aml_start(aml_get_default(), ticker);
aml_unref(ticker);
}
int main(int argc, char* argv[]) int main(int argc, char* argv[])
{ {
struct wayvnc self = { 0 }; struct wayvnc self = { 0 };
@ -660,9 +689,10 @@ int main(int argc, char* argv[])
const char* seat_name = NULL; const char* seat_name = NULL;
bool overlay_cursor = false; bool overlay_cursor = false;
bool show_performance = false;
int max_rate = 30; int max_rate = 30;
static const char* shortopts = "C:o:k:s:rf:h"; static const char* shortopts = "C:o:k:s:rf:hp";
int drm_fd = -1; int drm_fd = -1;
static const struct option longopts[] = { static const struct option longopts[] = {
@ -673,6 +703,7 @@ int main(int argc, char* argv[])
{ "render-cursor", no_argument, NULL, 'r' }, { "render-cursor", no_argument, NULL, 'r' },
{ "max-fps", required_argument, NULL, 'f' }, { "max-fps", required_argument, NULL, 'f' },
{ "help", no_argument, NULL, 'h' }, { "help", no_argument, NULL, 'h' },
{ "show-performance", no_argument, NULL, 'p' },
{ NULL, 0, NULL, 0 } { NULL, 0, NULL, 0 }
}; };
@ -700,6 +731,9 @@ int main(int argc, char* argv[])
case 'f': case 'f':
max_rate = atoi(optarg); max_rate = atoi(optarg);
break; break;
case 'p':
show_performance = true;
break;
case 'h': case 'h':
return wayvnc_usage(stdout, 0); return wayvnc_usage(stdout, 0);
default: default:
@ -839,6 +873,9 @@ int main(int argc, char* argv[])
if (wayvnc_start_capture(&self) < 0) if (wayvnc_start_capture(&self) < 0)
goto capture_failure; goto capture_failure;
if (show_performance)
start_performance_ticker(&self);
wl_display_dispatch(self.display); wl_display_dispatch(self.display);
while (!self.do_exit) { while (!self.do_exit) {