[mutter/gbsneto/charts: 2/4] clutter/stage: Account for frame times



commit 32b53712822ba822353d28df2153d2b3be4a7763
Author: Georges Basile Stavracas Neto <georges stavracas gmail com>
Date:   Thu Mar 21 11:27:26 2019 +0000

    clutter/stage: Account for frame times
    
    Instead of accumulating frames, simply calculate and
    debug-dump the time each frame takes to be drawn.
    
    Because we're using Clutter's debug machinery, it is
    structured and can be parsed by scripts.

 clutter/clutter/clutter-stage.c | 29 +++++------------------------
 1 file changed, 5 insertions(+), 24 deletions(-)
---
diff --git a/clutter/clutter/clutter-stage.c b/clutter/clutter/clutter-stage.c
index 44565cf85..3440d19a0 100644
--- a/clutter/clutter/clutter-stage.c
+++ b/clutter/clutter/clutter-stage.c
@@ -133,9 +133,6 @@ struct _ClutterStagePrivate
 
   gint sync_delay;
 
-  GTimer *fps_timer;
-  gint32 timer_n_frames;
-
   ClutterIDPool *pick_id_pool;
 
 #ifdef CLUTTER_ENABLE_DEBUG
@@ -1107,6 +1104,8 @@ clutter_stage_do_redraw (ClutterStage *stage)
 {
   ClutterActor *actor = CLUTTER_ACTOR (stage);
   ClutterStagePrivate *priv = stage->priv;
+  int64_t start;
+  int64_t end;
 
   if (CLUTTER_ACTOR_IN_DESTRUCTION (stage))
     return;
@@ -1118,28 +1117,13 @@ clutter_stage_do_redraw (ClutterStage *stage)
                 _clutter_actor_get_debug_name (actor),
                 stage);
 
-  if (CLUTTER_HAS_DEBUG (FRAME_TIME))
-    {
-      if (priv->fps_timer == NULL)
-        priv->fps_timer = g_timer_new ();
-    }
+  start = g_get_monotonic_time ();
 
   _clutter_stage_window_redraw (priv->impl);
 
-  if (CLUTTER_HAS_DEBUG (FRAME_TIME))
-    {
-      priv->timer_n_frames += 1;
+  end = g_get_monotonic_time ();
 
-      if (g_timer_elapsed (priv->fps_timer, NULL) >= 1.0)
-        {
-          g_print ("*** FPS for %s: %i ***\n",
-                   _clutter_actor_get_debug_name (actor),
-                   priv->timer_n_frames);
-
-          priv->timer_n_frames = 0;
-          g_timer_start (priv->fps_timer);
-        }
-    }
+  CLUTTER_NOTE (FRAME_TIME, "%lf", (end - start) / 1000.0);
 
   CLUTTER_NOTE (PAINT, "Redraw finished for stage '%s'[%p]",
                 _clutter_actor_get_debug_name (actor),
@@ -1886,9 +1870,6 @@ clutter_stage_finalize (GObject *object)
 
   _clutter_id_pool_free (priv->pick_id_pool);
 
-  if (priv->fps_timer != NULL)
-    g_timer_destroy (priv->fps_timer);
-
   if (priv->paint_notify != NULL)
     priv->paint_notify (priv->paint_data);
 


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]