[glib/g-property: 22/26] performance: Improve the granularity of the property tests
- From: Emmanuele Bassi <ebassi src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [glib/g-property: 22/26] performance: Improve the granularity of the property tests
- Date: Wed, 17 Aug 2011 14:00:35 +0000 (UTC)
commit 38284ddfdbfcac3886265960c7ffa9b2a24d7751
Author: Emmanuele Bassi <ebassi linux intel com>
Date: Fri Jul 8 15:40:15 2011 +0100
performance: Improve the granularity of the property tests
Split the two propert tests into four:
- direct C calls using struct access
- direct C calls using g_property_set()
- g_object_set() using GParamSpec
- g_object_set() using GProperty
tests/gobject/performance.c | 109 +++++++++++++++++++++++++++++++++++--------
1 files changed, 90 insertions(+), 19 deletions(-)
---
diff --git a/tests/gobject/performance.c b/tests/gobject/performance.c
index 4140e36..8971326 100644
--- a/tests/gobject/performance.c
+++ b/tests/gobject/performance.c
@@ -660,6 +660,18 @@ property_object_init (PropertyObject *self)
&(self->priv->baz));
}
+static void
+property_object_set_foo (PropertyObject *self, int value)
+{
+ g_property_set (((GProperty *) property_props[PROP_PROPERTY_FOO]), self, value);
+}
+
+static void
+property_object_set_baz (PropertyObject *self, float value)
+{
+ g_property_set (((GProperty *) property_props[PROP_PROPERTY_BAZ]), self, value);
+}
+
/*************************************************************
* Test object construction performance
*************************************************************/
@@ -751,7 +763,7 @@ test_construction_print_result (PerformanceTest *test,
#define NUM_ACCESSES_PER_ROUND 10000
struct PropertyTest {
- GObject *object;
+ gpointer object;
int n_accesses;
};
@@ -780,8 +792,26 @@ test_property_init (PerformanceTest *test,
}
static void
-test_property_run (PerformanceTest *test,
- gpointer _data)
+test_paramspec_direct_run (PerformanceTest *test,
+ gpointer _data)
+{
+ struct PropertyTest *data = _data;
+ int n_accesses, i;
+
+ n_accesses = data->n_accesses;
+ for (i = 0; i < n_accesses; i++)
+ {
+ gint foo = i % 16;
+ gfloat baz = foo * 3.14f;
+
+ paramspec_object_set_foo (data->object, foo);
+ paramspec_object_set_baz (data->object, baz);
+ }
+}
+
+static void
+test_paramspec_object_run (PerformanceTest *test,
+ gpointer _data)
{
struct PropertyTest *data = _data;
int n_accesses, i;
@@ -790,29 +820,50 @@ test_property_run (PerformanceTest *test,
for (i = 0; i < n_accesses; i++)
{
gint foo = i % 16;
- const gchar *bar = g_strdup_printf ("World/%d", foo);
gfloat baz = foo * 3.14f;
g_object_set (data->object,
"foo", foo,
- "bar", bar,
"baz", baz,
NULL);
}
+}
+static void
+test_property_direct_run (PerformanceTest *test,
+ gpointer _data)
+{
+ struct PropertyTest *data = _data;
+ int n_accesses, i;
+
+ n_accesses = data->n_accesses;
for (i = 0; i < n_accesses; i++)
{
- gint foo;
- gchar *bar;
- gfloat baz;
-
- g_object_get (data->object,
- "foo", &foo,
- "bar", &bar,
- "baz", &baz,
- NULL);
+ gint foo = i % 16;
+ gfloat baz = foo * 3.14f;
- g_free (bar);
+ property_object_set_foo (data->object, foo);
+ property_object_set_baz (data->object, baz);
+ }
+}
+
+static void
+test_property_object_run (PerformanceTest *test,
+ gpointer _data)
+{
+ struct PropertyTest *data = _data;
+ int n_accesses, i;
+
+ n_accesses = data->n_accesses;
+ for (i = 0; i < n_accesses; i++)
+ {
+ gint foo = i % 16;
+ gfloat baz = foo * 3.14f;
+
+ g_object_set (data->object,
+ "foo", foo,
+ "baz", baz,
+ NULL);
}
}
@@ -1032,21 +1083,41 @@ static PerformanceTest tests[] = {
test_construction_print_result
},
{
- "gparamspec-property",
+ "gparamspec-direct-set",
+ paramspec_object_get_type,
+ test_property_setup,
+ test_property_init,
+ test_paramspec_direct_run,
+ test_property_finish,
+ test_property_teardown,
+ test_property_print_result
+ },
+ {
+ "gproperty-direct-set",
+ property_object_get_type,
+ test_property_setup,
+ test_property_init,
+ test_property_direct_run,
+ test_property_finish,
+ test_property_teardown,
+ test_property_print_result
+ },
+ {
+ "gparamspec-gobject-access",
paramspec_object_get_type,
test_property_setup,
test_property_init,
- test_property_run,
+ test_paramspec_object_run,
test_property_finish,
test_property_teardown,
test_property_print_result
},
{
- "gproperty-property",
+ "gproperty-gobject-access",
property_object_get_type,
test_property_setup,
test_property_init,
- test_property_run,
+ test_property_object_run,
test_property_finish,
test_property_teardown,
test_property_print_result
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]