[gtk/glib-build-fix] testgtk: More GTimeVal eradication



commit f136a6f51f73acf2af906e327da5cc6807ed709b
Author: Matthias Clasen <mclasen redhat com>
Date:   Fri Jul 31 13:37:29 2020 -0400

    testgtk: More GTimeVal eradication

 tests/testgtk.c | 20 +++++++++-----------
 1 file changed, 9 insertions(+), 11 deletions(-)
---
diff --git a/tests/testgtk.c b/tests/testgtk.c
index 028985e63b..ad06542a8f 100644
--- a/tests/testgtk.c
+++ b/tests/testgtk.c
@@ -6029,7 +6029,7 @@ bench_iteration (GtkWidget *widget, void (* fn) (GtkWidget *widget))
 static void
 do_real_bench (GtkWidget *widget, void (* fn) (GtkWidget *widget), const char *name, int num)
 {
-  GTimeVal tv0, tv1;
+  gint64 t0, t1;
   double dt_first;
   double dt;
   int n;
@@ -6041,19 +6041,17 @@ do_real_bench (GtkWidget *widget, void (* fn) (GtkWidget *widget), const char *n
     printed_headers = TRUE;
   }
 
-  g_get_current_time (&tv0);
-  bench_iteration (widget, fn); 
-  g_get_current_time (&tv1);
+  t0 = g_get_monotonic_time ();
+  bench_iteration (widget, fn);
+  t1 = g_get_monotonic_time ();
 
-  dt_first = ((double)tv1.tv_sec - tv0.tv_sec) * 1000.0
-       + (tv1.tv_usec - tv0.tv_usec) / 1000.0;
+  dt_first = ((double)(t1 - t0)) / 1000.0;
 
-  g_get_current_time (&tv0);
+  t0 = g_get_monotonic_time ();
   for (n = 0; n < num - 1; n++)
-    bench_iteration (widget, fn); 
-  g_get_current_time (&tv1);
-  dt = ((double)tv1.tv_sec - tv0.tv_sec) * 1000.0
-       + (tv1.tv_usec - tv0.tv_usec) / 1000.0;
+    bench_iteration (widget, fn);
+  t1 = g_get_monotonic_time ();
+  dt = ((double)(t1 - t0)) / 1000.0;
 
   g_print ("%s %5d ", pad (name, 20), num);
   if (num > 1)


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