[glib] performance test: add signal test with args



commit 8bb6a4aec5dbc7535244a0fa2b96b728eebe75cc
Author: Ryan Lortie <desrt desrt ca>
Date:   Thu Feb 21 17:47:08 2013 +0000

    performance test: add signal test with args
    
    Add a signal that has some typical arguments (a uint and a pointer)
    since all of the other signal performance tests are for signals with no
    args.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=694380

 tests/gobject/performance.c |   45 +++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 45 insertions(+), 0 deletions(-)
---
diff --git a/tests/gobject/performance.c b/tests/gobject/performance.c
index d41955f..fdc51da 100644
--- a/tests/gobject/performance.c
+++ b/tests/gobject/performance.c
@@ -275,6 +275,7 @@ enum {
   COMPLEX_SIGNAL_EMPTY,
   COMPLEX_SIGNAL_GENERIC,
   COMPLEX_SIGNAL_GENERIC_EMPTY,
+  COMPLEX_SIGNAL_ARGS,
   COMPLEX_LAST_SIGNAL
 };
 
@@ -381,6 +382,15 @@ complex_object_class_init (ComplexObjectClass *class)
                  NULL,
                  G_TYPE_NONE, 0);
 
+  complex_signals[COMPLEX_SIGNAL_ARGS] =
+    g_signal_new ("signal-args",
+                  G_TYPE_FROM_CLASS (object_class),
+                  G_SIGNAL_RUN_FIRST,
+                  G_STRUCT_OFFSET (ComplexObjectClass, signal),
+                  NULL, NULL,
+                  g_cclosure_marshal_VOID__UINT_POINTER,
+                  G_TYPE_NONE, 2, G_TYPE_UINT, G_TYPE_POINTER);
+
   g_object_class_install_property (object_class,
                                   PROP_VAL1,
                                   g_param_spec_int ("val1",
@@ -622,6 +632,18 @@ test_emission_run (PerformanceTest *test,
     g_signal_emit (object, data->signal_id, 0);
 }
 
+static void
+test_emission_run_args (PerformanceTest *test,
+                        gpointer _data)
+{
+  struct EmissionTest *data = _data;
+  GObject *object = data->object;
+  int i;
+
+  for (i = 0; i < data->n_checks; i++)
+    g_signal_emit (object, data->signal_id, 0, 0, NULL);
+}
+
 /*************************************************************
  * Test signal unhandled emissions performance
  *************************************************************/
@@ -703,6 +725,9 @@ test_emission_handled_setup (PerformanceTest *test)
   g_signal_connect (data->object, "signal-generic-empty",
                     G_CALLBACK (test_emission_handled_handler),
                     NULL);
+  g_signal_connect (data->object, "signal-args",
+                    G_CALLBACK (test_emission_handled_handler),
+                    NULL);
 
   return data;
 }
@@ -820,6 +845,16 @@ static PerformanceTest tests[] = {
     test_emission_unhandled_print_result
   },
   {
+    "emit-unhandled-args",
+    GINT_TO_POINTER (COMPLEX_SIGNAL_ARGS),
+    test_emission_unhandled_setup,
+    test_emission_unhandled_init,
+    test_emission_run_args,
+    test_emission_unhandled_finish,
+    test_emission_unhandled_teardown,
+    test_emission_unhandled_print_result
+  },
+  {
     "emit-handled",
     GINT_TO_POINTER (COMPLEX_SIGNAL),
     test_emission_handled_setup,
@@ -858,6 +893,16 @@ static PerformanceTest tests[] = {
     test_emission_handled_finish,
     test_emission_handled_teardown,
     test_emission_handled_print_result
+  },
+  {
+    "emit-handled-args",
+    GINT_TO_POINTER (COMPLEX_SIGNAL_ARGS),
+    test_emission_handled_setup,
+    test_emission_handled_init,
+    test_emission_run_args,
+    test_emission_handled_finish,
+    test_emission_handled_teardown,
+    test_emission_handled_print_result
   }
 };
 


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