tests/performance: add "refcount-1" test

When an object has ref-count 1, then calling g_object_ref() requires a
check for toggle references. That is slower. Add a test for that case.
This commit is contained in:
Thomas Haller 2024-03-06 12:17:08 +01:00 committed by Philip Withnall
parent 282d536fd2
commit b6789dd1ea

View File

@ -1306,6 +1306,21 @@ test_refcount_run (PerformanceTest *test,
}
}
static void
test_refcount_1_run (PerformanceTest *test,
gpointer _data)
{
struct RefcountTest *data = _data;
GObject *object = data->object;
int i;
for (i = 0; i < data->n_checks; i++)
{
g_object_ref (object);
g_object_unref (object);
}
}
static void
test_refcount_finish (PerformanceTest *test,
gpointer _data)
@ -1576,7 +1591,17 @@ static PerformanceTest tests[] = {
test_refcount_finish,
test_refcount_teardown,
test_refcount_print_result
}
},
{
"refcount-1",
NULL,
test_refcount_setup,
test_refcount_init,
test_refcount_1_run,
test_refcount_finish,
test_refcount_teardown,
test_refcount_print_result
},
};
static PerformanceTest *