mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2025-04-23 15:49:16 +02:00
tests/performance: add "refcount-toggle" test
Performance test for emitting toggle reference notifications.
This commit is contained in:
parent
2b1a7e30b1
commit
7b9e6d4949
@ -1273,8 +1273,16 @@ test_get_teardown (PerformanceTest *test,
|
|||||||
struct RefcountTest {
|
struct RefcountTest {
|
||||||
GObject *object;
|
GObject *object;
|
||||||
int n_checks;
|
int n_checks;
|
||||||
|
gboolean is_toggle_ref;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
static void
|
||||||
|
test_refcount_toggle_ref_cb (gpointer data,
|
||||||
|
GObject *object,
|
||||||
|
gboolean is_last_ref)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
static gpointer
|
static gpointer
|
||||||
test_refcount_setup (PerformanceTest *test)
|
test_refcount_setup (PerformanceTest *test)
|
||||||
{
|
{
|
||||||
@ -1283,6 +1291,13 @@ test_refcount_setup (PerformanceTest *test)
|
|||||||
data = g_new0 (struct RefcountTest, 1);
|
data = g_new0 (struct RefcountTest, 1);
|
||||||
data->object = g_object_new (COMPLEX_TYPE_OBJECT, NULL);
|
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;
|
return data;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1357,7 +1372,11 @@ test_refcount_teardown (PerformanceTest *test,
|
|||||||
{
|
{
|
||||||
struct RefcountTest *data = _data;
|
struct RefcountTest *data = _data;
|
||||||
|
|
||||||
|
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_object_unref (data->object);
|
||||||
|
|
||||||
g_free (data);
|
g_free (data);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1616,6 +1635,16 @@ static PerformanceTest tests[] = {
|
|||||||
test_refcount_teardown,
|
test_refcount_teardown,
|
||||||
test_refcount_print_result
|
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 *
|
static PerformanceTest *
|
||||||
|
Loading…
x
Reference in New Issue
Block a user