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 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 * enought 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
);
128 for (i
= 0; i
< num_rounds
; i
++)
130 test
->init (test
, data
, factor
);
131 g_timer_start (timer
);
132 test
->run (test
, data
);
133 g_timer_stop (timer
);
134 test
->finish (test
, data
);
135 elapsed
= g_timer_elapsed (timer
, NULL
);
138 max_elapsed
= min_elapsed
= avg_elapsed
= elapsed
;
141 min_elapsed
= MIN (min_elapsed
, elapsed
);
142 max_elapsed
= MAX (max_elapsed
, elapsed
);
143 avg_elapsed
+= elapsed
;
147 avg_elapsed
= avg_elapsed
/ num_rounds
;
151 g_print ("Minimum corrected round time: %.2f msecs\n", min_elapsed
* 1000);
152 g_print ("Maximum corrected round time: %.2f msecs\n", max_elapsed
* 1000);
153 g_print ("Average corrected round time: %.2f msecs\n", avg_elapsed
* 1000);
155 /* Print the results */
156 test
->print_result (test
, data
, min_elapsed
);
159 test
->teardown (test
, data
);
160 g_timer_destroy (timer
);
163 /*************************************************************
164 * Simple object is a very simple small GObject subclass
165 * with no properties, no signals, implementing no interfaces
166 *************************************************************/
168 static GType
simple_object_get_type (void);
169 #define SIMPLE_TYPE_OBJECT (simple_object_get_type ())
170 typedef struct _SimpleObject SimpleObject
;
171 typedef struct _SimpleObjectClass SimpleObjectClass
;
175 GObject parent_instance
;
179 struct _SimpleObjectClass
181 GObjectClass parent_class
;
184 G_DEFINE_TYPE (SimpleObject
, simple_object
, G_TYPE_OBJECT
)
187 simple_object_finalize (GObject
*object
)
189 G_OBJECT_CLASS (simple_object_parent_class
)->finalize (object
);
193 simple_object_class_init (SimpleObjectClass
*class)
195 GObjectClass
*object_class
= G_OBJECT_CLASS (class);
197 object_class
->finalize
= simple_object_finalize
;
201 simple_object_init (SimpleObject
*simple_object
)
203 simple_object
->val
= 42;
206 typedef struct _TestIfaceClass TestIfaceClass
;
207 typedef struct _TestIfaceClass TestIface1Class
;
208 typedef struct _TestIfaceClass TestIface2Class
;
209 typedef struct _TestIfaceClass TestIface3Class
;
210 typedef struct _TestIfaceClass TestIface4Class
;
211 typedef struct _TestIfaceClass TestIface5Class
;
212 typedef struct _TestIface TestIface
;
214 struct _TestIfaceClass
216 GTypeInterface base_iface
;
217 void (*method
) (TestIface
*obj
);
220 static GType
test_iface1_get_type (void);
221 static GType
test_iface2_get_type (void);
222 static GType
test_iface3_get_type (void);
223 static GType
test_iface4_get_type (void);
224 static GType
test_iface5_get_type (void);
226 #define TEST_TYPE_IFACE1 (test_iface1_get_type ())
227 #define TEST_TYPE_IFACE2 (test_iface2_get_type ())
228 #define TEST_TYPE_IFACE3 (test_iface3_get_type ())
229 #define TEST_TYPE_IFACE4 (test_iface4_get_type ())
230 #define TEST_TYPE_IFACE5 (test_iface5_get_type ())
232 static DEFINE_IFACE (TestIface1
, test_iface1
, NULL
, NULL
)
233 static DEFINE_IFACE (TestIface2
, test_iface2
, NULL
, NULL
)
234 static DEFINE_IFACE (TestIface3
, test_iface3
, NULL
, NULL
)
235 static DEFINE_IFACE (TestIface4
, test_iface4
, NULL
, NULL
)
236 static DEFINE_IFACE (TestIface5
, test_iface5
, NULL
, NULL
)
238 /*************************************************************
239 * Complex object is a GObject subclass with a properties,
240 * construct properties, signals and implementing an interface.
241 *************************************************************/
243 static GType
complex_object_get_type (void);
244 #define COMPLEX_TYPE_OBJECT (complex_object_get_type ())
245 typedef struct _ComplexObject ComplexObject
;
246 typedef struct _ComplexObjectClass ComplexObjectClass
;
248 struct _ComplexObject
250 GObject parent_instance
;
255 struct _ComplexObjectClass
257 GObjectClass parent_class
;
259 void (*signal
) (ComplexObject
*obj
);
260 void (*signal_empty
) (ComplexObject
*obj
);
263 static void complex_test_iface_init (gpointer g_iface
,
264 gpointer iface_data
);
266 G_DEFINE_TYPE_EXTENDED (ComplexObject
, complex_object
,
268 G_IMPLEMENT_INTERFACE (TEST_TYPE_IFACE1
, complex_test_iface_init
)
269 G_IMPLEMENT_INTERFACE (TEST_TYPE_IFACE2
, complex_test_iface_init
)
270 G_IMPLEMENT_INTERFACE (TEST_TYPE_IFACE3
, complex_test_iface_init
)
271 G_IMPLEMENT_INTERFACE (TEST_TYPE_IFACE4
, complex_test_iface_init
)
272 G_IMPLEMENT_INTERFACE (TEST_TYPE_IFACE5
, complex_test_iface_init
))
274 #define COMPLEX_OBJECT(object) (G_TYPE_CHECK_INSTANCE_CAST ((object), COMPLEX_TYPE_OBJECT, ComplexObject))
284 COMPLEX_SIGNAL_EMPTY
,
285 COMPLEX_SIGNAL_GENERIC
,
286 COMPLEX_SIGNAL_GENERIC_EMPTY
,
291 static guint complex_signals
[COMPLEX_LAST_SIGNAL
] = { 0 };
294 complex_object_finalize (GObject
*object
)
296 G_OBJECT_CLASS (complex_object_parent_class
)->finalize (object
);
300 complex_object_set_property (GObject
*object
,
305 ComplexObject
*complex = COMPLEX_OBJECT (object
);
310 complex->val1
= g_value_get_int (value
);
313 complex->val2
= g_value_get_int (value
);
316 G_OBJECT_WARN_INVALID_PROPERTY_ID (object
, prop_id
, pspec
);
322 complex_object_get_property (GObject
*object
,
327 ComplexObject
*complex = COMPLEX_OBJECT (object
);
332 g_value_set_int (value
, complex->val1
);
335 g_value_set_int (value
, complex->val2
);
338 G_OBJECT_WARN_INVALID_PROPERTY_ID (object
, prop_id
, pspec
);
344 complex_object_real_signal (ComplexObject
*obj
)
349 complex_object_class_init (ComplexObjectClass
*class)
351 GObjectClass
*object_class
= G_OBJECT_CLASS (class);
353 object_class
->finalize
= complex_object_finalize
;
354 object_class
->set_property
= complex_object_set_property
;
355 object_class
->get_property
= complex_object_get_property
;
357 class->signal
= complex_object_real_signal
;
359 complex_signals
[COMPLEX_SIGNAL
] =
360 g_signal_new ("signal",
361 G_TYPE_FROM_CLASS (object_class
),
363 G_STRUCT_OFFSET (ComplexObjectClass
, signal
),
365 g_cclosure_marshal_VOID__VOID
,
368 complex_signals
[COMPLEX_SIGNAL_EMPTY
] =
369 g_signal_new ("signal-empty",
370 G_TYPE_FROM_CLASS (object_class
),
372 G_STRUCT_OFFSET (ComplexObjectClass
, signal_empty
),
374 g_cclosure_marshal_VOID__VOID
,
377 complex_signals
[COMPLEX_SIGNAL_GENERIC
] =
378 g_signal_new ("signal-generic",
379 G_TYPE_FROM_CLASS (object_class
),
381 G_STRUCT_OFFSET (ComplexObjectClass
, signal
),
385 complex_signals
[COMPLEX_SIGNAL_GENERIC_EMPTY
] =
386 g_signal_new ("signal-generic-empty",
387 G_TYPE_FROM_CLASS (object_class
),
389 G_STRUCT_OFFSET (ComplexObjectClass
, signal_empty
),
394 complex_signals
[COMPLEX_SIGNAL_ARGS
] =
395 g_signal_new ("signal-args",
396 G_TYPE_FROM_CLASS (object_class
),
398 G_STRUCT_OFFSET (ComplexObjectClass
, signal
),
400 g_cclosure_marshal_VOID__UINT_POINTER
,
401 G_TYPE_NONE
, 2, G_TYPE_UINT
, G_TYPE_POINTER
);
403 g_object_class_install_property (object_class
,
405 g_param_spec_int ("val1",
411 G_PARAM_CONSTRUCT
| G_PARAM_READWRITE
));
412 g_object_class_install_property (object_class
,
414 g_param_spec_int ("val2",
426 complex_object_iface_method (TestIface
*obj
)
428 ComplexObject
*complex = COMPLEX_OBJECT (obj
);
433 complex_test_iface_init (gpointer g_iface
,
436 TestIfaceClass
*iface
= g_iface
;
437 iface
->method
= complex_object_iface_method
;
441 complex_object_init (ComplexObject
*complex_object
)
443 complex_object
->val2
= 43;
446 /*************************************************************
447 * Test object construction performance
448 *************************************************************/
450 #define NUM_OBJECT_TO_CONSTRUCT 10000
452 struct ConstructionTest
{
459 test_construction_setup (PerformanceTest
*test
)
461 struct ConstructionTest
*data
;
463 data
= g_new0 (struct ConstructionTest
, 1);
464 data
->type
= ((GType (*)(void))test
->extra_data
)();
470 test_construction_init (PerformanceTest
*test
,
474 struct ConstructionTest
*data
= _data
;
477 n
= NUM_OBJECT_TO_CONSTRUCT
* count_factor
;
478 if (data
->n_objects
!= n
)
481 data
->objects
= g_new (GObject
*, n
);
486 test_construction_run (PerformanceTest
*test
,
489 struct ConstructionTest
*data
= _data
;
490 GObject
**objects
= data
->objects
;
491 GType type
= data
->type
;
494 n_objects
= data
->n_objects
;
495 for (i
= 0; i
< n_objects
; i
++)
496 objects
[i
] = g_object_new (type
, NULL
);
500 test_construction_finish (PerformanceTest
*test
,
503 struct ConstructionTest
*data
= _data
;
506 for (i
= 0; i
< data
->n_objects
; i
++)
507 g_object_unref (data
->objects
[i
]);
511 test_construction_teardown (PerformanceTest
*test
,
514 struct ConstructionTest
*data
= _data
;
515 g_free (data
->objects
);
520 test_construction_print_result (PerformanceTest
*test
,
524 struct ConstructionTest
*data
= _data
;
526 g_print ("Millions of constructed objects per second: %.3f\n",
527 data
->n_objects
/ (time
* 1000000));
530 /*************************************************************
531 * Test runtime type check performance
532 *************************************************************/
534 #define NUM_KILO_CHECKS_PER_ROUND 50
536 struct TypeCheckTest
{
542 test_type_check_setup (PerformanceTest
*test
)
544 struct TypeCheckTest
*data
;
546 data
= g_new0 (struct TypeCheckTest
, 1);
547 data
->object
= g_object_new (COMPLEX_TYPE_OBJECT
, NULL
);
553 test_type_check_init (PerformanceTest
*test
,
557 struct TypeCheckTest
*data
= _data
;
559 data
->n_checks
= factor
* NUM_KILO_CHECKS_PER_ROUND
;
563 /* Work around g_type_check_instance_is_a being marked "pure",
564 and thus only called once for the loop. */
565 gboolean (*my_type_check_instance_is_a
) (GTypeInstance
*type_instance
,
566 GType iface_type
) = &g_type_check_instance_is_a
;
569 test_type_check_run (PerformanceTest
*test
,
572 struct TypeCheckTest
*data
= _data
;
573 volatile GObject
*object
= data
->object
;
574 volatile GType type
, types
[5];
577 types
[0] = test_iface1_get_type ();
578 types
[1] = test_iface2_get_type ();
579 types
[2] = test_iface3_get_type ();
580 types
[3] = test_iface4_get_type ();
581 types
[4] = test_iface5_get_type ();
583 for (i
= 0; i
< data
->n_checks
; i
++)
586 for (j
= 0; j
< 1000; j
++)
588 my_type_check_instance_is_a ((GTypeInstance
*)object
,
595 test_type_check_finish (PerformanceTest
*test
,
601 test_type_check_print_result (PerformanceTest
*test
,
605 struct TypeCheckTest
*data
= _data
;
606 g_print ("Million type checks per second: %.2f\n",
607 data
->n_checks
/ (1000*time
));
611 test_type_check_teardown (PerformanceTest
*test
,
614 struct TypeCheckTest
*data
= _data
;
616 g_object_unref (data
->object
);
620 /*************************************************************
621 * Test signal emissions performance (common code)
622 *************************************************************/
624 #define NUM_EMISSIONS_PER_ROUND 10000
626 struct EmissionTest
{
633 test_emission_run (PerformanceTest
*test
,
636 struct EmissionTest
*data
= _data
;
637 GObject
*object
= data
->object
;
640 for (i
= 0; i
< data
->n_checks
; i
++)
641 g_signal_emit (object
, data
->signal_id
, 0);
645 test_emission_run_args (PerformanceTest
*test
,
648 struct EmissionTest
*data
= _data
;
649 GObject
*object
= data
->object
;
652 for (i
= 0; i
< data
->n_checks
; i
++)
653 g_signal_emit (object
, data
->signal_id
, 0, 0, NULL
);
656 /*************************************************************
657 * Test signal unhandled emissions performance
658 *************************************************************/
661 test_emission_unhandled_setup (PerformanceTest
*test
)
663 struct EmissionTest
*data
;
665 data
= g_new0 (struct EmissionTest
, 1);
666 data
->object
= g_object_new (COMPLEX_TYPE_OBJECT
, NULL
);
667 data
->signal_id
= complex_signals
[GPOINTER_TO_INT (test
->extra_data
)];
672 test_emission_unhandled_init (PerformanceTest
*test
,
676 struct EmissionTest
*data
= _data
;
678 data
->n_checks
= factor
* NUM_EMISSIONS_PER_ROUND
;
682 test_emission_unhandled_finish (PerformanceTest
*test
,
688 test_emission_unhandled_print_result (PerformanceTest
*test
,
692 struct EmissionTest
*data
= _data
;
694 g_print ("Emissions per second: %.0f\n",
695 data
->n_checks
/ time
);
699 test_emission_unhandled_teardown (PerformanceTest
*test
,
702 struct EmissionTest
*data
= _data
;
704 g_object_unref (data
->object
);
708 /*************************************************************
709 * Test signal handled emissions performance
710 *************************************************************/
713 test_emission_handled_handler (ComplexObject
*obj
, gpointer data
)
718 test_emission_handled_setup (PerformanceTest
*test
)
720 struct EmissionTest
*data
;
722 data
= g_new0 (struct EmissionTest
, 1);
723 data
->object
= g_object_new (COMPLEX_TYPE_OBJECT
, NULL
);
724 data
->signal_id
= complex_signals
[GPOINTER_TO_INT (test
->extra_data
)];
725 g_signal_connect (data
->object
, "signal",
726 G_CALLBACK (test_emission_handled_handler
),
728 g_signal_connect (data
->object
, "signal-empty",
729 G_CALLBACK (test_emission_handled_handler
),
731 g_signal_connect (data
->object
, "signal-generic",
732 G_CALLBACK (test_emission_handled_handler
),
734 g_signal_connect (data
->object
, "signal-generic-empty",
735 G_CALLBACK (test_emission_handled_handler
),
737 g_signal_connect (data
->object
, "signal-args",
738 G_CALLBACK (test_emission_handled_handler
),
745 test_emission_handled_init (PerformanceTest
*test
,
749 struct EmissionTest
*data
= _data
;
751 data
->n_checks
= factor
* NUM_EMISSIONS_PER_ROUND
;
755 test_emission_handled_finish (PerformanceTest
*test
,
761 test_emission_handled_print_result (PerformanceTest
*test
,
765 struct EmissionTest
*data
= _data
;
767 g_print ("Emissions per second: %.0f\n",
768 data
->n_checks
/ time
);
772 test_emission_handled_teardown (PerformanceTest
*test
,
775 struct EmissionTest
*data
= _data
;
777 g_object_unref (data
->object
);
781 /*************************************************************
782 * Test object refcount performance
783 *************************************************************/
785 #define NUM_KILO_REFS_PER_ROUND 100000
787 struct RefcountTest
{
793 test_refcount_setup (PerformanceTest
*test
)
795 struct RefcountTest
*data
;
797 data
= g_new0 (struct RefcountTest
, 1);
798 data
->object
= g_object_new (COMPLEX_TYPE_OBJECT
, NULL
);
804 test_refcount_init (PerformanceTest
*test
,
808 struct RefcountTest
*data
= _data
;
810 data
->n_checks
= factor
* NUM_KILO_REFS_PER_ROUND
;
814 test_refcount_run (PerformanceTest
*test
,
817 struct RefcountTest
*data
= _data
;
818 GObject
*object
= data
->object
;
821 for (i
= 0; i
< data
->n_checks
; i
++)
823 g_object_ref (object
);
824 g_object_ref (object
);
825 g_object_ref (object
);
826 g_object_unref (object
);
827 g_object_unref (object
);
829 g_object_ref (object
);
830 g_object_ref (object
);
831 g_object_unref (object
);
832 g_object_unref (object
);
833 g_object_unref (object
);
838 test_refcount_finish (PerformanceTest
*test
,
844 test_refcount_print_result (PerformanceTest
*test
,
848 struct RefcountTest
*data
= _data
;
849 g_print ("Million refs+unref per second: %.2f\n",
850 data
->n_checks
* 5 / (time
* 1000000 ));
854 test_refcount_teardown (PerformanceTest
*test
,
857 struct RefcountTest
*data
= _data
;
859 g_object_unref (data
->object
);
863 /*************************************************************
865 *************************************************************/
867 static PerformanceTest tests
[] = {
869 "simple-construction",
870 simple_object_get_type
,
871 test_construction_setup
,
872 test_construction_init
,
873 test_construction_run
,
874 test_construction_finish
,
875 test_construction_teardown
,
876 test_construction_print_result
879 "complex-construction",
880 complex_object_get_type
,
881 test_construction_setup
,
882 test_construction_init
,
883 test_construction_run
,
884 test_construction_finish
,
885 test_construction_teardown
,
886 test_construction_print_result
891 test_type_check_setup
,
892 test_type_check_init
,
894 test_type_check_finish
,
895 test_type_check_teardown
,
896 test_type_check_print_result
900 GINT_TO_POINTER (COMPLEX_SIGNAL
),
901 test_emission_unhandled_setup
,
902 test_emission_unhandled_init
,
904 test_emission_unhandled_finish
,
905 test_emission_unhandled_teardown
,
906 test_emission_unhandled_print_result
909 "emit-unhandled-empty",
910 GINT_TO_POINTER (COMPLEX_SIGNAL_EMPTY
),
911 test_emission_unhandled_setup
,
912 test_emission_unhandled_init
,
914 test_emission_unhandled_finish
,
915 test_emission_unhandled_teardown
,
916 test_emission_unhandled_print_result
919 "emit-unhandled-generic",
920 GINT_TO_POINTER (COMPLEX_SIGNAL_GENERIC
),
921 test_emission_unhandled_setup
,
922 test_emission_unhandled_init
,
924 test_emission_unhandled_finish
,
925 test_emission_unhandled_teardown
,
926 test_emission_unhandled_print_result
929 "emit-unhandled-generic-empty",
930 GINT_TO_POINTER (COMPLEX_SIGNAL_GENERIC_EMPTY
),
931 test_emission_unhandled_setup
,
932 test_emission_unhandled_init
,
934 test_emission_unhandled_finish
,
935 test_emission_unhandled_teardown
,
936 test_emission_unhandled_print_result
939 "emit-unhandled-args",
940 GINT_TO_POINTER (COMPLEX_SIGNAL_ARGS
),
941 test_emission_unhandled_setup
,
942 test_emission_unhandled_init
,
943 test_emission_run_args
,
944 test_emission_unhandled_finish
,
945 test_emission_unhandled_teardown
,
946 test_emission_unhandled_print_result
950 GINT_TO_POINTER (COMPLEX_SIGNAL
),
951 test_emission_handled_setup
,
952 test_emission_handled_init
,
954 test_emission_handled_finish
,
955 test_emission_handled_teardown
,
956 test_emission_handled_print_result
959 "emit-handled-empty",
960 GINT_TO_POINTER (COMPLEX_SIGNAL_EMPTY
),
961 test_emission_handled_setup
,
962 test_emission_handled_init
,
964 test_emission_handled_finish
,
965 test_emission_handled_teardown
,
966 test_emission_handled_print_result
969 "emit-handled-generic",
970 GINT_TO_POINTER (COMPLEX_SIGNAL_GENERIC
),
971 test_emission_handled_setup
,
972 test_emission_handled_init
,
974 test_emission_handled_finish
,
975 test_emission_handled_teardown
,
976 test_emission_handled_print_result
979 "emit-handled-generic-empty",
980 GINT_TO_POINTER (COMPLEX_SIGNAL_GENERIC_EMPTY
),
981 test_emission_handled_setup
,
982 test_emission_handled_init
,
984 test_emission_handled_finish
,
985 test_emission_handled_teardown
,
986 test_emission_handled_print_result
990 GINT_TO_POINTER (COMPLEX_SIGNAL_ARGS
),
991 test_emission_handled_setup
,
992 test_emission_handled_init
,
993 test_emission_run_args
,
994 test_emission_handled_finish
,
995 test_emission_handled_teardown
,
996 test_emission_handled_print_result
1001 test_refcount_setup
,
1004 test_refcount_finish
,
1005 test_refcount_teardown
,
1006 test_refcount_print_result
1010 static PerformanceTest
*
1011 find_test (const char *name
)
1014 for (i
= 0; i
< G_N_ELEMENTS (tests
); i
++)
1016 if (strcmp (tests
[i
].name
, name
) == 0)
1025 PerformanceTest
*test
;
1026 GOptionContext
*context
;
1027 GError
*error
= NULL
;
1030 context
= g_option_context_new ("GObject performance tests");
1031 g_option_context_add_main_entries (context
, cmd_entries
, NULL
);
1032 if (!g_option_context_parse (context
, &argc
, &argv
, &error
))
1034 g_printerr ("%s: %s\n", argv
[0], error
->message
);
1040 for (i
= 1; i
< argc
; i
++)
1042 test
= find_test (argv
[i
]);
1049 for (i
= 0; i
< G_N_ELEMENTS (tests
); i
++)
1050 run_test (&tests
[i
]);