mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2025-04-23 07:39:17 +02:00
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:
parent
282d536fd2
commit
b6789dd1ea
@ -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
|
static void
|
||||||
test_refcount_finish (PerformanceTest *test,
|
test_refcount_finish (PerformanceTest *test,
|
||||||
gpointer _data)
|
gpointer _data)
|
||||||
@ -1576,7 +1591,17 @@ static PerformanceTest tests[] = {
|
|||||||
test_refcount_finish,
|
test_refcount_finish,
|
||||||
test_refcount_teardown,
|
test_refcount_teardown,
|
||||||
test_refcount_print_result
|
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 *
|
static PerformanceTest *
|
||||||
|
Loading…
x
Reference in New Issue
Block a user