Add FPS profiling (set DEBUG_FPS when running tint2)
This commit is contained in:
27
src/tint.c
27
src/tint.c
@@ -79,6 +79,8 @@ XSettingsClient *xsettings_client = NULL;
|
|||||||
timeout *detect_compositor_timer = NULL;
|
timeout *detect_compositor_timer = NULL;
|
||||||
int detect_compositor_timer_counter = 0;
|
int detect_compositor_timer_counter = 0;
|
||||||
|
|
||||||
|
gboolean debug_fps = FALSE;
|
||||||
|
|
||||||
void detect_compositor(void *arg)
|
void detect_compositor(void *arg)
|
||||||
{
|
{
|
||||||
if (server.composite_manager) {
|
if (server.composite_manager) {
|
||||||
@@ -376,6 +378,7 @@ void init(int argc, char *argv[])
|
|||||||
|
|
||||||
debug_geometry = getenv("DEBUG_GEOMETRY") != NULL;
|
debug_geometry = getenv("DEBUG_GEOMETRY") != NULL;
|
||||||
debug_gradients = getenv("DEBUG_GRADIENTS") != NULL;
|
debug_gradients = getenv("DEBUG_GRADIENTS") != NULL;
|
||||||
|
debug_fps = getenv("DEBUG_FPS") != NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int sigchild_pipe_valid = FALSE;
|
static int sigchild_pipe_valid = FALSE;
|
||||||
@@ -1560,8 +1563,14 @@ start:
|
|||||||
int ufd = uevent_init();
|
int ufd = uevent_init();
|
||||||
int hidden_dnd = 0;
|
int hidden_dnd = 0;
|
||||||
|
|
||||||
|
double ts_event_read = 0;
|
||||||
|
double ts_event_processed = 0;
|
||||||
|
double ts_render_finished = 0;
|
||||||
|
double ts_flush_finished = 0;
|
||||||
while (1) {
|
while (1) {
|
||||||
if (panel_refresh) {
|
if (panel_refresh) {
|
||||||
|
if (debug_fps)
|
||||||
|
ts_event_processed = get_time();
|
||||||
if (systray_profile)
|
if (systray_profile)
|
||||||
fprintf(stderr,
|
fprintf(stderr,
|
||||||
BLUE "[%f] %s:%d redrawing panel" RESET "\n",
|
BLUE "[%f] %s:%d redrawing panel" RESET "\n",
|
||||||
@@ -1635,7 +1644,23 @@ start:
|
|||||||
0);
|
0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (debug_fps)
|
||||||
|
ts_render_finished = get_time();
|
||||||
XFlush(server.display);
|
XFlush(server.display);
|
||||||
|
if (debug_fps) {
|
||||||
|
ts_flush_finished = get_time();
|
||||||
|
double period = ts_flush_finished - ts_event_read;
|
||||||
|
double fps = 1.0 / period;
|
||||||
|
double proc_ratio = (ts_event_processed - ts_event_read) / period;
|
||||||
|
double render_ratio = (ts_render_finished - ts_event_processed) / period;
|
||||||
|
double flush_ratio = (ts_flush_finished - ts_render_finished) / period;
|
||||||
|
fprintf(stderr,
|
||||||
|
BLUE "fps = %.1f : processing %.1f%%, rendering %.1f%%, flushing %.1f%%" RESET "\n",
|
||||||
|
fps,
|
||||||
|
proc_ratio * 100,
|
||||||
|
render_ratio * 100,
|
||||||
|
flush_ratio * 100);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Create a File Description Set containing x11_fd
|
// Create a File Description Set containing x11_fd
|
||||||
@@ -1686,6 +1711,8 @@ start:
|
|||||||
if (XPending(server.display) > 0) {
|
if (XPending(server.display) > 0) {
|
||||||
XEvent e;
|
XEvent e;
|
||||||
XNextEvent(server.display, &e);
|
XNextEvent(server.display, &e);
|
||||||
|
if (debug_fps)
|
||||||
|
ts_event_read = get_time();
|
||||||
#if HAVE_SN
|
#if HAVE_SN
|
||||||
if (startup_notifications)
|
if (startup_notifications)
|
||||||
sn_display_process_event(server.sn_display, &e);
|
sn_display_process_event(server.sn_display, &e);
|
||||||
|
|||||||
Reference in New Issue
Block a user