1 /* GObject - GLib Type, Object, Parameter and Signal Library
2 * Copyright (C) 2009 Red Hat, Inc.
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2.1 of the License, or (at your option) any later version.
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
14 * You should have received a copy of the GNU Lesser General
15 * Public License along with this library; if not, see <http://www.gnu.org/licenses/>.
20 #include <glib-object.h>
21 #include "../testcommon.h"
23 #define WARM_UP_N_RUNS 50
24 #define ESTIMATE_ROUND_TIME_N_RUNS 5
25 #define DEFAULT_TEST_TIME 15 /* seconds */
26 /* The time we want each round to take, in seconds, this should
27 * be large enough compared to the timer resolution, but small
28 * enough that the risk of any random slowness will miss the
30 #define TARGET_ROUND_TIME 0.008
32 static gboolean verbose = FALSE;
33 static int test_length = DEFAULT_TEST_TIME;
35 static GOptionEntry cmd_entries[] = {
36 {"verbose", 'v', 0, G_OPTION_ARG_NONE, &verbose,
37 "Print extra information", NULL},
38 {"seconds", 's', 0, G_OPTION_ARG_INT, &test_length,
39 "Time to run each test in seconds", NULL},
43 typedef struct _PerformanceTest PerformanceTest;
44 struct _PerformanceTest {
48 gpointer (*setup) (PerformanceTest *test);
49 void (*init) (PerformanceTest *test,
52 void (*run) (PerformanceTest *test,
54 void (*finish) (PerformanceTest *test,
56 void (*teardown) (PerformanceTest *test,
58 void (*print_result) (PerformanceTest *test,
64 run_test (PerformanceTest *test)
67 guint64 i, num_rounds;
68 double elapsed, min_elapsed, max_elapsed, avg_elapsed, factor;
71 g_print ("Running test %s\n", test->name);
74 timer = g_timer_new ();
75 data = test->setup (test);
78 g_print ("Warming up\n");
80 g_timer_start (timer);
82 /* Warm up the test by doing a few runs */
83 for (i = 0; i < WARM_UP_N_RUNS; i++)
85 test->init (test, data, 1.0);
86 test->run (test, data);
87 test->finish (test, data);
91 elapsed = g_timer_elapsed (timer, NULL);
95 g_print ("Warm up time: %.2f secs\n", elapsed);
96 g_print ("Estimating round time\n");
99 /* Estimate time for one run by doing a few test rounds */
101 for (i = 0; i < ESTIMATE_ROUND_TIME_N_RUNS; i++)
103 test->init (test, data, 1.0);
104 g_timer_start (timer);
105 test->run (test, data);
106 g_timer_stop (timer);
107 test->finish (test, data);
109 elapsed = g_timer_elapsed (timer, NULL);
111 min_elapsed = elapsed;
113 min_elapsed = MIN (min_elapsed, elapsed);
116 factor = TARGET_ROUND_TIME / min_elapsed;
119 g_print ("Uncorrected round time: %.4f msecs, correction factor %.2f\n", 1000*min_elapsed, factor);
121 /* Calculate number of rounds needed */
122 num_rounds = (test_length / TARGET_ROUND_TIME) + 1;
125 g_print ("Running %"G_GINT64_MODIFIER"d rounds\n", num_rounds);
131 for (i = 0; i < num_rounds; i++)
133 test->init (test, data, factor);
134 g_timer_start (timer);
135 test->run (test, data);
136 g_timer_stop (timer);
137 test->finish (test, data);
138 elapsed = g_timer_elapsed (timer, NULL);
141 max_elapsed = min_elapsed = avg_elapsed = elapsed;
144 min_elapsed = MIN (min_elapsed, elapsed);
145 max_elapsed = MAX (max_elapsed, elapsed);
146 avg_elapsed += elapsed;
151 avg_elapsed = avg_elapsed / num_rounds;
155 g_print ("Minimum corrected round time: %.2f msecs\n", min_elapsed * 1000);
156 g_print ("Maximum corrected round time: %.2f msecs\n", max_elapsed * 1000);
157 g_print ("Average corrected round time: %.2f msecs\n", avg_elapsed * 1000);
160 /* Print the results */
161 test->print_result (test, data, min_elapsed);
164 test->teardown (test, data);
165 g_timer_destroy (timer);
168 /*************************************************************
169 * Simple object is a very simple small GObject subclass
170 * with no properties, no signals, implementing no interfaces
171 *************************************************************/
173 static GType simple_object_get_type (void);
174 #define SIMPLE_TYPE_OBJECT (simple_object_get_type ())
175 typedef struct _SimpleObject SimpleObject;
176 typedef struct _SimpleObjectClass SimpleObjectClass;
180 GObject parent_instance;
184 struct _SimpleObjectClass
186 GObjectClass parent_class;
189 G_DEFINE_TYPE (SimpleObject, simple_object, G_TYPE_OBJECT)
192 simple_object_finalize (GObject *object)
194 G_OBJECT_CLASS (simple_object_parent_class)->finalize (object);
198 simple_object_class_init (SimpleObjectClass *class)
200 GObjectClass *object_class = G_OBJECT_CLASS (class);
202 object_class->finalize = simple_object_finalize;
206 simple_object_init (SimpleObject *simple_object)
208 simple_object->val = 42;
211 typedef struct _TestIfaceClass TestIfaceClass;
212 typedef struct _TestIfaceClass TestIface1Class;
213 typedef struct _TestIfaceClass TestIface2Class;
214 typedef struct _TestIfaceClass TestIface3Class;
215 typedef struct _TestIfaceClass TestIface4Class;
216 typedef struct _TestIfaceClass TestIface5Class;
217 typedef struct _TestIface TestIface;
219 struct _TestIfaceClass
221 GTypeInterface base_iface;
222 void (*method) (TestIface *obj);
225 static GType test_iface1_get_type (void);
226 static GType test_iface2_get_type (void);
227 static GType test_iface3_get_type (void);
228 static GType test_iface4_get_type (void);
229 static GType test_iface5_get_type (void);
231 #define TEST_TYPE_IFACE1 (test_iface1_get_type ())
232 #define TEST_TYPE_IFACE2 (test_iface2_get_type ())
233 #define TEST_TYPE_IFACE3 (test_iface3_get_type ())
234 #define TEST_TYPE_IFACE4 (test_iface4_get_type ())
235 #define TEST_TYPE_IFACE5 (test_iface5_get_type ())
237 static DEFINE_IFACE (TestIface1, test_iface1, NULL, NULL)
238 static DEFINE_IFACE (TestIface2, test_iface2, NULL, NULL)
239 static DEFINE_IFACE (TestIface3, test_iface3, NULL, NULL)
240 static DEFINE_IFACE (TestIface4, test_iface4, NULL, NULL)
241 static DEFINE_IFACE (TestIface5, test_iface5, NULL, NULL)
243 /*************************************************************
244 * Complex object is a GObject subclass with a properties,
245 * construct properties, signals and implementing an interface.
246 *************************************************************/
248 static GType complex_object_get_type (void);
249 #define COMPLEX_TYPE_OBJECT (complex_object_get_type ())
250 typedef struct _ComplexObject ComplexObject;
251 typedef struct _ComplexObjectClass ComplexObjectClass;
253 struct _ComplexObject
255 GObject parent_instance;
260 struct _ComplexObjectClass
262 GObjectClass parent_class;
264 void (*signal) (ComplexObject *obj);
265 void (*signal_empty) (ComplexObject *obj);
268 static void complex_test_iface_init (gpointer g_iface,
269 gpointer iface_data);
271 G_DEFINE_TYPE_EXTENDED (ComplexObject, complex_object,
273 G_IMPLEMENT_INTERFACE (TEST_TYPE_IFACE1, complex_test_iface_init)
274 G_IMPLEMENT_INTERFACE (TEST_TYPE_IFACE2, complex_test_iface_init)
275 G_IMPLEMENT_INTERFACE (TEST_TYPE_IFACE3, complex_test_iface_init)
276 G_IMPLEMENT_INTERFACE (TEST_TYPE_IFACE4, complex_test_iface_init)
277 G_IMPLEMENT_INTERFACE (TEST_TYPE_IFACE5, complex_test_iface_init))
279 #define COMPLEX_OBJECT(object) (G_TYPE_CHECK_INSTANCE_CAST ((object), COMPLEX_TYPE_OBJECT, ComplexObject))
288 static GParamSpec *pspecs[N_PROPERTIES] = { NULL, };
292 COMPLEX_SIGNAL_EMPTY,
293 COMPLEX_SIGNAL_GENERIC,
294 COMPLEX_SIGNAL_GENERIC_EMPTY,
299 static guint complex_signals[COMPLEX_LAST_SIGNAL] = { 0 };
302 complex_object_finalize (GObject *object)
304 ComplexObject *c = COMPLEX_OBJECT (object);
308 G_OBJECT_CLASS (complex_object_parent_class)->finalize (object);
312 complex_object_set_property (GObject *object,
317 ComplexObject *complex = COMPLEX_OBJECT (object);
322 complex->val1 = g_value_get_int (value);
325 g_free (complex->val2);
326 complex->val2 = g_value_dup_string (value);
329 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
335 complex_object_get_property (GObject *object,
340 ComplexObject *complex = COMPLEX_OBJECT (object);
345 g_value_set_int (value, complex->val1);
348 g_value_set_string (value, complex->val2);
351 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
357 complex_object_real_signal (ComplexObject *obj)
362 complex_object_class_init (ComplexObjectClass *class)
364 GObjectClass *object_class = G_OBJECT_CLASS (class);
366 object_class->finalize = complex_object_finalize;
367 object_class->set_property = complex_object_set_property;
368 object_class->get_property = complex_object_get_property;
370 class->signal = complex_object_real_signal;
372 complex_signals[COMPLEX_SIGNAL] =
373 g_signal_new ("signal",
374 G_TYPE_FROM_CLASS (object_class),
376 G_STRUCT_OFFSET (ComplexObjectClass, signal),
378 g_cclosure_marshal_VOID__VOID,
381 complex_signals[COMPLEX_SIGNAL_EMPTY] =
382 g_signal_new ("signal-empty",
383 G_TYPE_FROM_CLASS (object_class),
385 G_STRUCT_OFFSET (ComplexObjectClass, signal_empty),
387 g_cclosure_marshal_VOID__VOID,
390 complex_signals[COMPLEX_SIGNAL_GENERIC] =
391 g_signal_new ("signal-generic",
392 G_TYPE_FROM_CLASS (object_class),
394 G_STRUCT_OFFSET (ComplexObjectClass, signal),
398 complex_signals[COMPLEX_SIGNAL_GENERIC_EMPTY] =
399 g_signal_new ("signal-generic-empty",
400 G_TYPE_FROM_CLASS (object_class),
402 G_STRUCT_OFFSET (ComplexObjectClass, signal_empty),
407 complex_signals[COMPLEX_SIGNAL_ARGS] =
408 g_signal_new ("signal-args",
409 G_TYPE_FROM_CLASS (object_class),
411 G_STRUCT_OFFSET (ComplexObjectClass, signal),
413 g_cclosure_marshal_VOID__UINT_POINTER,
414 G_TYPE_NONE, 2, G_TYPE_UINT, G_TYPE_POINTER);
416 pspecs[PROP_VAL1] = g_param_spec_int ("val1", "val1", "val1",
418 G_PARAM_STATIC_STRINGS | G_PARAM_CONSTRUCT | G_PARAM_READWRITE);
419 pspecs[PROP_VAL2] = g_param_spec_string ("val2", "val2", "val2",
421 G_PARAM_STATIC_STRINGS | G_PARAM_READWRITE);
423 g_object_class_install_properties (object_class, N_PROPERTIES, pspecs);
427 complex_object_iface_method (TestIface *obj)
429 ComplexObject *complex = COMPLEX_OBJECT (obj);
434 complex_test_iface_init (gpointer g_iface,
437 TestIfaceClass *iface = g_iface;
438 iface->method = complex_object_iface_method;
442 complex_object_init (ComplexObject *complex_object)
444 complex_object->val1 = 42;
447 /*************************************************************
448 * Test object construction performance
449 *************************************************************/
451 #define NUM_OBJECT_TO_CONSTRUCT 10000
453 struct ConstructionTest {
460 test_construction_setup (PerformanceTest *test)
462 struct ConstructionTest *data;
464 data = g_new0 (struct ConstructionTest, 1);
465 data->type = ((GType (*)(void))test->extra_data)();
471 test_construction_init (PerformanceTest *test,
475 struct ConstructionTest *data = _data;
478 n = NUM_OBJECT_TO_CONSTRUCT * count_factor;
479 if (data->n_objects != n)
482 data->objects = g_renew (GObject *, data->objects, n);
487 test_construction_run (PerformanceTest *test,
490 struct ConstructionTest *data = _data;
491 GObject **objects = data->objects;
492 GType type = data->type;
495 n_objects = data->n_objects;
496 for (i = 0; i < n_objects; i++)
497 objects[i] = g_object_new (type, NULL);
501 test_construction_run1 (PerformanceTest *test,
504 struct ConstructionTest *data = _data;
505 GObject **objects = data->objects;
508 n_objects = data->n_objects;
509 for (i = 0; i < n_objects; i++)
510 objects[i] = (GObject *) g_slice_new0 (SimpleObject);
514 test_complex_construction_run (PerformanceTest *test,
517 struct ConstructionTest *data = _data;
518 GObject **objects = data->objects;
519 GType type = data->type;
522 n_objects = data->n_objects;
523 for (i = 0; i < n_objects; i++)
524 objects[i] = g_object_new (type, "val1", 5, "val2", "thousand", NULL);
528 test_complex_construction_run1 (PerformanceTest *test,
531 struct ConstructionTest *data = _data;
532 GObject **objects = data->objects;
533 GType type = data->type;
536 n_objects = data->n_objects;
537 for (i = 0; i < n_objects; i++)
539 ComplexObject *object;
540 object = (ComplexObject *)g_object_new (type, NULL);
542 object->val2 = g_strdup ("thousand");
543 objects[i] = (GObject *)object;
548 test_complex_construction_run2 (PerformanceTest *test,
551 struct ConstructionTest *data = _data;
552 GObject **objects = data->objects;
553 GType type = data->type;
556 n_objects = data->n_objects;
557 for (i = 0; i < n_objects; i++)
559 objects[i] = g_object_new (type, NULL);
564 test_construction_finish (PerformanceTest *test,
567 struct ConstructionTest *data = _data;
570 for (i = 0; i < data->n_objects; i++)
571 g_object_unref (data->objects[i]);
575 test_construction_finish1 (PerformanceTest *test,
578 struct ConstructionTest *data = _data;
581 for (i = 0; i < data->n_objects; i++)
582 g_slice_free (SimpleObject, (SimpleObject *)data->objects[i]);
586 test_construction_teardown (PerformanceTest *test,
589 struct ConstructionTest *data = _data;
590 g_free (data->objects);
595 test_finalization_init (PerformanceTest *test,
599 struct ConstructionTest *data = _data;
602 n = NUM_OBJECT_TO_CONSTRUCT * count_factor;
603 if (data->n_objects != n)
606 data->objects = g_renew (GObject *, data->objects, n);
609 for (int i = 0; i < data->n_objects; i++)
611 data->objects[i] = g_object_new (data->type, NULL);
616 test_finalization_run (PerformanceTest *test,
619 struct ConstructionTest *data = _data;
620 GObject **objects = data->objects;
623 n_objects = data->n_objects;
624 for (i = 0; i < n_objects; i++)
626 g_object_unref (objects[i]);
631 test_finalization_finish (PerformanceTest *test,
637 test_construction_print_result (PerformanceTest *test,
641 struct ConstructionTest *data = _data;
643 g_print ("Millions of constructed objects per second: %.3f\n",
644 data->n_objects / (time * 1000000));
648 test_finalization_print_result (PerformanceTest *test,
652 struct ConstructionTest *data = _data;
654 g_print ("Millions of finalized objects per second: %.3f\n",
655 data->n_objects / (time * 1000000));
658 /*************************************************************
659 * Test runtime type check performance
660 *************************************************************/
662 #define NUM_KILO_CHECKS_PER_ROUND 50
664 struct TypeCheckTest {
670 test_type_check_setup (PerformanceTest *test)
672 struct TypeCheckTest *data;
674 data = g_new0 (struct TypeCheckTest, 1);
675 data->object = g_object_new (COMPLEX_TYPE_OBJECT, NULL);
681 test_type_check_init (PerformanceTest *test,
685 struct TypeCheckTest *data = _data;
687 data->n_checks = factor * NUM_KILO_CHECKS_PER_ROUND;
691 /* Work around g_type_check_instance_is_a being marked "pure",
692 and thus only called once for the loop. */
693 gboolean (*my_type_check_instance_is_a) (GTypeInstance *type_instance,
694 GType iface_type) = &g_type_check_instance_is_a;
697 test_type_check_run (PerformanceTest *test,
700 struct TypeCheckTest *data = _data;
701 GObject *object = data->object;
702 GType type, types[5];
705 types[0] = test_iface1_get_type ();
706 types[1] = test_iface2_get_type ();
707 types[2] = test_iface3_get_type ();
708 types[3] = test_iface4_get_type ();
709 types[4] = test_iface5_get_type ();
711 for (i = 0; i < data->n_checks; i++)
714 for (j = 0; j < 1000; j++)
716 my_type_check_instance_is_a ((GTypeInstance *)object,
723 test_type_check_finish (PerformanceTest *test,
729 test_type_check_print_result (PerformanceTest *test,
733 struct TypeCheckTest *data = _data;
734 g_print ("Million type checks per second: %.2f\n",
735 data->n_checks / (1000*time));
739 test_type_check_teardown (PerformanceTest *test,
742 struct TypeCheckTest *data = _data;
744 g_object_unref (data->object);
748 /*************************************************************
749 * Test signal emissions performance (common code)
750 *************************************************************/
752 #define NUM_EMISSIONS_PER_ROUND 10000
754 struct EmissionTest {
761 test_emission_run (PerformanceTest *test,
764 struct EmissionTest *data = _data;
765 GObject *object = data->object;
768 for (i = 0; i < data->n_checks; i++)
769 g_signal_emit (object, data->signal_id, 0);
773 test_emission_run_args (PerformanceTest *test,
776 struct EmissionTest *data = _data;
777 GObject *object = data->object;
780 for (i = 0; i < data->n_checks; i++)
781 g_signal_emit (object, data->signal_id, 0, 0, NULL);
784 /*************************************************************
785 * Test signal unhandled emissions performance
786 *************************************************************/
789 test_emission_unhandled_setup (PerformanceTest *test)
791 struct EmissionTest *data;
793 data = g_new0 (struct EmissionTest, 1);
794 data->object = g_object_new (COMPLEX_TYPE_OBJECT, NULL);
795 data->signal_id = complex_signals[GPOINTER_TO_INT (test->extra_data)];
800 test_emission_unhandled_init (PerformanceTest *test,
804 struct EmissionTest *data = _data;
806 data->n_checks = factor * NUM_EMISSIONS_PER_ROUND;
810 test_emission_unhandled_finish (PerformanceTest *test,
816 test_emission_unhandled_print_result (PerformanceTest *test,
820 struct EmissionTest *data = _data;
822 g_print ("Emissions per second: %.0f\n",
823 data->n_checks / time);
827 test_emission_unhandled_teardown (PerformanceTest *test,
830 struct EmissionTest *data = _data;
832 g_object_unref (data->object);
836 /*************************************************************
837 * Test signal handled emissions performance
838 *************************************************************/
841 test_emission_handled_handler (ComplexObject *obj, gpointer data)
846 test_emission_handled_setup (PerformanceTest *test)
848 struct EmissionTest *data;
850 data = g_new0 (struct EmissionTest, 1);
851 data->object = g_object_new (COMPLEX_TYPE_OBJECT, NULL);
852 data->signal_id = complex_signals[GPOINTER_TO_INT (test->extra_data)];
853 g_signal_connect (data->object, "signal",
854 G_CALLBACK (test_emission_handled_handler),
856 g_signal_connect (data->object, "signal-empty",
857 G_CALLBACK (test_emission_handled_handler),
859 g_signal_connect (data->object, "signal-generic",
860 G_CALLBACK (test_emission_handled_handler),
862 g_signal_connect (data->object, "signal-generic-empty",
863 G_CALLBACK (test_emission_handled_handler),
865 g_signal_connect (data->object, "signal-args",
866 G_CALLBACK (test_emission_handled_handler),
873 test_emission_handled_init (PerformanceTest *test,
877 struct EmissionTest *data = _data;
879 data->n_checks = factor * NUM_EMISSIONS_PER_ROUND;
883 test_emission_handled_finish (PerformanceTest *test,
889 test_emission_handled_print_result (PerformanceTest *test,
893 struct EmissionTest *data = _data;
895 g_print ("Emissions per second: %.0f\n",
896 data->n_checks / time);
900 test_emission_handled_teardown (PerformanceTest *test,
903 struct EmissionTest *data = _data;
905 g_object_unref (data->object);
909 /*************************************************************
910 * Test object refcount performance
911 *************************************************************/
913 #define NUM_KILO_REFS_PER_ROUND 100000
915 struct RefcountTest {
921 test_refcount_setup (PerformanceTest *test)
923 struct RefcountTest *data;
925 data = g_new0 (struct RefcountTest, 1);
926 data->object = g_object_new (COMPLEX_TYPE_OBJECT, NULL);
932 test_refcount_init (PerformanceTest *test,
936 struct RefcountTest *data = _data;
938 data->n_checks = factor * NUM_KILO_REFS_PER_ROUND;
942 test_refcount_run (PerformanceTest *test,
945 struct RefcountTest *data = _data;
946 GObject *object = data->object;
949 for (i = 0; i < data->n_checks; i++)
951 g_object_ref (object);
952 g_object_ref (object);
953 g_object_ref (object);
954 g_object_unref (object);
955 g_object_unref (object);
957 g_object_ref (object);
958 g_object_ref (object);
959 g_object_unref (object);
960 g_object_unref (object);
961 g_object_unref (object);
966 test_refcount_finish (PerformanceTest *test,
972 test_refcount_print_result (PerformanceTest *test,
976 struct RefcountTest *data = _data;
977 g_print ("Million refs+unref per second: %.2f\n",
978 data->n_checks * 5 / (time * 1000000 ));
982 test_refcount_teardown (PerformanceTest *test,
985 struct RefcountTest *data = _data;
987 g_object_unref (data->object);
991 /*************************************************************
993 *************************************************************/
995 static PerformanceTest tests[] = {
997 "simple-construction",
998 simple_object_get_type,
999 test_construction_setup,
1000 test_construction_init,
1001 test_construction_run,
1002 test_construction_finish,
1003 test_construction_teardown,
1004 test_construction_print_result
1007 "simple-construction1",
1008 simple_object_get_type,
1009 test_construction_setup,
1010 test_construction_init,
1011 test_construction_run1,
1012 test_construction_finish1,
1013 test_construction_teardown,
1014 test_construction_print_result
1017 "complex-construction",
1018 complex_object_get_type,
1019 test_construction_setup,
1020 test_construction_init,
1021 test_complex_construction_run,
1022 test_construction_finish,
1023 test_construction_teardown,
1024 test_construction_print_result
1027 "complex-construction1",
1028 complex_object_get_type,
1029 test_construction_setup,
1030 test_construction_init,
1031 test_complex_construction_run1,
1032 test_construction_finish,
1033 test_construction_teardown,
1034 test_construction_print_result
1037 "complex-construction2",
1038 complex_object_get_type,
1039 test_construction_setup,
1040 test_construction_init,
1041 test_complex_construction_run2,
1042 test_construction_finish,
1043 test_construction_teardown,
1044 test_construction_print_result
1048 simple_object_get_type,
1049 test_construction_setup,
1050 test_finalization_init,
1051 test_finalization_run,
1052 test_finalization_finish,
1053 test_construction_teardown,
1054 test_finalization_print_result
1059 test_type_check_setup,
1060 test_type_check_init,
1061 test_type_check_run,
1062 test_type_check_finish,
1063 test_type_check_teardown,
1064 test_type_check_print_result
1068 GINT_TO_POINTER (COMPLEX_SIGNAL),
1069 test_emission_unhandled_setup,
1070 test_emission_unhandled_init,
1072 test_emission_unhandled_finish,
1073 test_emission_unhandled_teardown,
1074 test_emission_unhandled_print_result
1077 "emit-unhandled-empty",
1078 GINT_TO_POINTER (COMPLEX_SIGNAL_EMPTY),
1079 test_emission_unhandled_setup,
1080 test_emission_unhandled_init,
1082 test_emission_unhandled_finish,
1083 test_emission_unhandled_teardown,
1084 test_emission_unhandled_print_result
1087 "emit-unhandled-generic",
1088 GINT_TO_POINTER (COMPLEX_SIGNAL_GENERIC),
1089 test_emission_unhandled_setup,
1090 test_emission_unhandled_init,
1092 test_emission_unhandled_finish,
1093 test_emission_unhandled_teardown,
1094 test_emission_unhandled_print_result
1097 "emit-unhandled-generic-empty",
1098 GINT_TO_POINTER (COMPLEX_SIGNAL_GENERIC_EMPTY),
1099 test_emission_unhandled_setup,
1100 test_emission_unhandled_init,
1102 test_emission_unhandled_finish,
1103 test_emission_unhandled_teardown,
1104 test_emission_unhandled_print_result
1107 "emit-unhandled-args",
1108 GINT_TO_POINTER (COMPLEX_SIGNAL_ARGS),
1109 test_emission_unhandled_setup,
1110 test_emission_unhandled_init,
1111 test_emission_run_args,
1112 test_emission_unhandled_finish,
1113 test_emission_unhandled_teardown,
1114 test_emission_unhandled_print_result
1118 GINT_TO_POINTER (COMPLEX_SIGNAL),
1119 test_emission_handled_setup,
1120 test_emission_handled_init,
1122 test_emission_handled_finish,
1123 test_emission_handled_teardown,
1124 test_emission_handled_print_result
1127 "emit-handled-empty",
1128 GINT_TO_POINTER (COMPLEX_SIGNAL_EMPTY),
1129 test_emission_handled_setup,
1130 test_emission_handled_init,
1132 test_emission_handled_finish,
1133 test_emission_handled_teardown,
1134 test_emission_handled_print_result
1137 "emit-handled-generic",
1138 GINT_TO_POINTER (COMPLEX_SIGNAL_GENERIC),
1139 test_emission_handled_setup,
1140 test_emission_handled_init,
1142 test_emission_handled_finish,
1143 test_emission_handled_teardown,
1144 test_emission_handled_print_result
1147 "emit-handled-generic-empty",
1148 GINT_TO_POINTER (COMPLEX_SIGNAL_GENERIC_EMPTY),
1149 test_emission_handled_setup,
1150 test_emission_handled_init,
1152 test_emission_handled_finish,
1153 test_emission_handled_teardown,
1154 test_emission_handled_print_result
1157 "emit-handled-args",
1158 GINT_TO_POINTER (COMPLEX_SIGNAL_ARGS),
1159 test_emission_handled_setup,
1160 test_emission_handled_init,
1161 test_emission_run_args,
1162 test_emission_handled_finish,
1163 test_emission_handled_teardown,
1164 test_emission_handled_print_result
1169 test_refcount_setup,
1172 test_refcount_finish,
1173 test_refcount_teardown,
1174 test_refcount_print_result
1178 static PerformanceTest *
1179 find_test (const char *name)
1182 for (i = 0; i < G_N_ELEMENTS (tests); i++)
1184 if (strcmp (tests[i].name, name) == 0)
1193 PerformanceTest *test;
1194 GOptionContext *context;
1195 GError *error = NULL;
1198 context = g_option_context_new ("GObject performance tests");
1199 g_option_context_add_main_entries (context, cmd_entries, NULL);
1200 if (!g_option_context_parse (context, &argc, &argv, &error))
1202 g_printerr ("%s: %s\n", argv[0], error->message);
1208 for (i = 1; i < argc; i++)
1210 test = find_test (argv[i]);
1218 for (k = 0; k < G_N_ELEMENTS (tests); k++)
1219 run_test (&tests[k]);
1222 g_option_context_free (context);