tests/performance: add "refcount-toggle" test

Performance test for emitting toggle reference notifications.
This commit is contained in:
Thomas Haller 2024-03-06 18:21:40 +01:00 committed by Philip Withnall
parent 2b1a7e30b1
commit 7b9e6d4949

View File

@ -1273,8 +1273,16 @@ test_get_teardown (PerformanceTest *test,
struct RefcountTest {
GObject *object;
int n_checks;
gboolean is_toggle_ref;
};
static void
test_refcount_toggle_ref_cb (gpointer data,
GObject *object,
gboolean is_last_ref)
{
}
static gpointer
test_refcount_setup (PerformanceTest *test)
{
@ -1283,6 +1291,13 @@ test_refcount_setup (PerformanceTest *test)
data = g_new0 (struct RefcountTest, 1);
data->object = g_object_new (COMPLEX_TYPE_OBJECT, NULL);
if (g_str_equal (test->name, "refcount-toggle"))
{
g_object_add_toggle_ref (data->object, test_refcount_toggle_ref_cb, NULL);
g_object_unref (data->object);
data->is_toggle_ref = TRUE;
}
return data;
}
@ -1357,7 +1372,11 @@ test_refcount_teardown (PerformanceTest *test,
{
struct RefcountTest *data = _data;
g_object_unref (data->object);
if (data->is_toggle_ref)
g_object_remove_toggle_ref (data->object, test_refcount_toggle_ref_cb, NULL);
else
g_object_unref (data->object);
g_free (data);
}
@ -1616,6 +1635,16 @@ static PerformanceTest tests[] = {
test_refcount_teardown,
test_refcount_print_result
},
{
"refcount-toggle",
NULL,
test_refcount_setup,
test_refcount_init,
test_refcount_1_run,
test_refcount_finish,
test_refcount_teardown,
test_refcount_print_result
},
};
static PerformanceTest *