From d94affec0e772e529479b0a4624464690919fed4 Mon Sep 17 00:00:00 2001 From: Vito Caputo Date: Wed, 11 Jan 2023 13:59:57 -0800 Subject: fps: move FPS printing to stderr With --print-pipes there will be a potential shitload of stuff getting printed out, and it'd be nice to easily distinguish that content from the FPS counter. Since stderr is normally less buffered than stdout (line buffered) not lose debugging information, just put the low-bandwidth periodic FPS print there instead. This leaves stdout for --print-pipes output which occurs every frame *and* may have a lot of content per print. --- src/fps.c | 4 ++-- src/fps.h | 4 +++- src/main.c | 2 +- 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/src/fps.c b/src/fps.c index 30b65cf..bb4107c 100644 --- a/src/fps.c +++ b/src/fps.c @@ -36,7 +36,7 @@ int fps_setup(void) } -void fps_print(til_fb_t *fb) +void fps_fprint(til_fb_t *fb, FILE *out) { #ifdef __WIN32__ @@ -47,7 +47,7 @@ void fps_print(til_fb_t *fb) return; til_fb_get_put_pages_count(fb, &n); - printf("FPS: %u\n", n); + fprintf(out, "FPS: %u\n", n); print_fps = 0; #endif diff --git a/src/fps.h b/src/fps.h index 1afb566..ede9efb 100644 --- a/src/fps.h +++ b/src/fps.h @@ -1,9 +1,11 @@ #ifndef _FPS_H #define _FPS_H +#include + #include "til_fb.h" int fps_setup(void); -void fps_print(til_fb_t *fb); +void fps_fprint(til_fb_t *fb, FILE *out); #endif diff --git a/src/main.c b/src/main.c index 943a8ff..0718bfd 100644 --- a/src/main.c +++ b/src/main.c @@ -398,7 +398,7 @@ int main(int argc, const char *argv[]) if (til_fb_flip(rototiller.fb) < 0) break; - fps_print(rototiller.fb); + fps_fprint(rototiller.fb, stderr); } pthread_cancel(rototiller.thread); -- cgit v1.2.1