[gtk/arraystore-perf: 4/4] perf test: Add GtkArrayStore
- From: Matthias Clasen <matthiasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk/arraystore-perf: 4/4] perf test: Add GtkArrayStore
- Date: Fri, 3 Jul 2020 23:56:15 +0000 (UTC)
commit d233b10559fed312442a1c7b31c5a173b8e7e577
Author: Matthias Clasen <mclasen redhat com>
Date: Thu Jul 2 16:34:20 2020 -0400
perf test: Add GtkArrayStore
testsuite/gtk/listmodel-performance.c | 54 ++++++++++++++++++++++++++++++++---
1 file changed, 50 insertions(+), 4 deletions(-)
---
diff --git a/testsuite/gtk/listmodel-performance.c b/testsuite/gtk/listmodel-performance.c
index 8e9f4e9c36..f4ac3828ea 100644
--- a/testsuite/gtk/listmodel-performance.c
+++ b/testsuite/gtk/listmodel-performance.c
@@ -41,6 +41,29 @@ make_list_store (guint n_items)
return G_LIST_MODEL (store);
}
+static GListModel *
+make_array_store (guint n_items)
+{
+ GtkArrayStore *store;
+ guint i;
+
+ store = gtk_array_store_new (GTK_TYPE_STRING_OBJECT);
+
+ for (i = 0; i < n_items; i++)
+ {
+ char *string;
+ gpointer obj;
+
+ string = g_strdup_printf ("item %d", i);
+ obj = get_object (string);
+ gtk_array_store_append (store, obj);
+ g_object_unref (obj);
+ g_free (string);
+ }
+
+ return G_LIST_MODEL (store);
+}
+
static GListModel *
make_string_list2 (guint n_items)
{
@@ -94,6 +117,8 @@ do_random_access (const char *kind,
if (strcmp (kind, "liststore") == 0)
model = make_list_store (size);
+ else if (strcmp (kind, "arraystore") == 0)
+ model = make_array_store (size);
else if (strcmp (kind, "stringlist") == 0)
model = make_string_list2 (size);
else if (strcmp (kind, "array stringlist") == 0)
@@ -134,6 +159,8 @@ do_linear_access (const char *kind,
if (strcmp (kind, "liststore") == 0)
model = make_list_store (size);
+ else if (strcmp (kind, "arraystore") == 0)
+ model = make_array_store (size);
else if (strcmp (kind, "stringlist") == 0)
model = make_string_list2 (size);
else if (strcmp (kind, "array stringlist") == 0)
@@ -177,6 +204,8 @@ do_append (const char *kind,
{
if (strcmp (kind, "liststore") == 0)
model = make_list_store (0);
+ else if (strcmp (kind, "arraystore") == 0)
+ model = make_array_store (0);
else if (strcmp (kind, "stringlist") == 0)
model = make_string_list2 (0);
else if (strcmp (kind, "array stringlist") == 0)
@@ -196,6 +225,12 @@ do_append (const char *kind,
g_list_store_append (G_LIST_STORE (model), obj);
g_object_unref (obj);
}
+ else if (strcmp (kind, "arraystore") == 0)
+ {
+ gpointer obj = get_object (string);
+ gtk_array_store_append (GTK_ARRAY_STORE (model), obj);
+ g_object_unref (obj);
+ }
else if (strcmp (kind, "stringlist") == 0)
gtk_string_list2_append (GTK_STRING_LIST2 (model), string);
else if (strcmp (kind, "array stringlist") == 0)
@@ -213,6 +248,9 @@ do_append (const char *kind,
g_print ("\"append\", \"%s\", %u, %g\n", kind, size, ((double)total) / iterations);
}
+#define gtk_array_store_insert(store,position,item) \
+ gtk_array_store_splice (store, position, 0, (gpointer *)&item, 1)
+
static void
do_insert (const char *kind,
guint size)
@@ -230,6 +268,8 @@ do_insert (const char *kind,
{
if (strcmp (kind, "liststore") == 0)
model = make_list_store (1);
+ else if (strcmp (kind, "arraystore") == 0)
+ model = make_array_store (1);
else if (strcmp (kind, "stringlist") == 0)
model = make_string_list2 (1);
else if (strcmp (kind, "array stringlist") == 0)
@@ -250,6 +290,12 @@ do_insert (const char *kind,
g_list_store_insert (G_LIST_STORE (model), position, obj);
g_object_unref (obj);
}
+ else if (strcmp (kind, "arraystore") == 0)
+ {
+ gpointer obj = get_object (string);
+ gtk_array_store_insert (GTK_ARRAY_STORE (model), position, obj);
+ g_object_unref (obj);
+ }
else if (strcmp (kind, "stringlist") == 0)
gtk_string_list2_splice (GTK_STRING_LIST2 (model), position, 0,
(const char * const []){string, NULL});
@@ -272,7 +318,7 @@ do_insert (const char *kind,
static void
random_access (void)
{
- const char *kind[] = { "liststore", "stringlist", "array stringlist" };
+ const char *kind[] = { "liststore", "arraystore", "stringlist", "array stringlist" };
int sizes = 22;
int size;
int i, j;
@@ -285,7 +331,7 @@ random_access (void)
static void
linear_access (void)
{
- const char *kind[] = { "liststore", "stringlist", "array stringlist" };
+ const char *kind[] = { "liststore", "arraystore", "stringlist", "array stringlist" };
int sizes = 22;
int size;
int i, j;
@@ -298,7 +344,7 @@ linear_access (void)
static void
append (void)
{
- const char *kind[] = { "liststore", "stringlist", "array stringlist" };
+ const char *kind[] = { "liststore", "arraystore", "stringlist", "array stringlist" };
int sizes = 22;
int size;
int i, j;
@@ -311,7 +357,7 @@ append (void)
static void
insert (void)
{
- const char *kind[] = { "liststore", "stringlist", "array stringlist" };
+ const char *kind[] = { "liststore", "arraystore", "stringlist", "array stringlist" };
int sizes = 22;
int size;
int i, j;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]