From b6789dd1ea3b3fd851dbc931045625ca9589bc79 Mon Sep 17 00:00:00 2001 From: Thomas Haller Date: Wed, 6 Mar 2024 12:17:08 +0100 Subject: [PATCH] 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. --- gobject/tests/performance/performance.c | 27 ++++++++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-) diff --git a/gobject/tests/performance/performance.c b/gobject/tests/performance/performance.c index a08539e0e..e6f09fc86 100644 --- a/gobject/tests/performance/performance.c +++ b/gobject/tests/performance/performance.c @@ -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 *