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
This commit is contained in:
Ryan Lortie 2013-02-21 17:47:08 +00:00 committed by Matthias Clasen
parent 4b72bbf9b1
commit 8bb6a4aec5

View File

@ -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;
}
@ -819,6 +844,16 @@ static PerformanceTest tests[] = {
test_emission_unhandled_teardown,
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),
@ -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
}
};