[gtk+/quartz-integration: 384/563] tree-performance: test with tree stores too
- From: John Ralls <jralls src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk+/quartz-integration: 384/563] tree-performance: test with tree stores too
- Date: Sat, 9 Jul 2011 06:38:18 +0000 (UTC)
commit 4c85741b4e76ef759b63e491996792bcd98de7d1
Author: Matthias Clasen <mclasen redhat com>
Date: Wed Jun 22 23:02:24 2011 -0400
tree-performance: test with tree stores too
This duplicates the current test with a GtkTreeStore instead
of a GtkListStore.
tests/a11y/tree-performance.c | 157 +++++++++++++++++++++++++++++++++++++++--
1 files changed, 152 insertions(+), 5 deletions(-)
---
diff --git a/tests/a11y/tree-performance.c b/tests/a11y/tree-performance.c
index 76865a6..1361f07 100644
--- a/tests/a11y/tree-performance.c
+++ b/tests/a11y/tree-performance.c
@@ -22,7 +22,7 @@
#include <gtk/gtk.h>
-const gchar treeui[] =
+const gchar list_ui[] =
"<interface>"
" <object class='GtkListStore' id='liststore1'>"
" <columns>"
@@ -125,7 +125,7 @@ builder_get_toplevel (GtkBuilder *builder)
}
static void
-populate_tree (GtkBuilder *builder)
+populate_list (GtkBuilder *builder)
{
GtkTreeView *tv;
GtkListStore *store;
@@ -144,6 +144,151 @@ populate_tree (GtkBuilder *builder)
}
static void
+test_performance_list (void)
+{
+ GtkBuilder *builder;
+ gdouble elapsed;
+ GtkWidget *window;
+ GError *error = NULL;
+
+ builder = gtk_builder_new ();
+ gtk_builder_add_from_string (builder, list_ui, -1, &error);
+ g_assert_no_error (error);
+ window = builder_get_toplevel (builder);
+ g_assert (window);
+
+ gtk_widget_show (window);
+
+ g_test_timer_start ();
+
+ populate_list (builder);
+
+ elapsed = g_test_timer_elapsed ();
+ g_test_minimized_result (elapsed, "large list test: %gsec", elapsed);
+ g_object_unref (builder);
+}
+
+static void
+test_a11y_performance_list (void)
+{
+ GtkBuilder *builder;
+ gdouble elapsed;
+ GtkWidget *window;
+ GError *error = NULL;
+ gint count_before;
+ gint count_after;
+
+ builder = gtk_builder_new ();
+ gtk_builder_add_from_string (builder, list_ui, -1, &error);
+ g_assert_no_error (error);
+ window = builder_get_toplevel (builder);
+ g_assert (window);
+
+ gtk_widget_show (window);
+
+ g_test_timer_start ();
+
+ /* make sure all accessibles exist */
+ count_before = 0;
+ walk_accessible_tree (gtk_widget_get_accessible (window), &count_before);
+
+ populate_list (builder);
+
+ /* for good measure, do this again */
+ count_after = 0;
+ walk_accessible_tree (gtk_widget_get_accessible (window), &count_after);
+
+ elapsed = g_test_timer_elapsed ();
+ g_test_minimized_result (elapsed, "large list with a11y: %gsec", elapsed);
+ g_object_unref (builder);
+
+ g_test_message ("%d accessibles before, %d after\n", count_before, count_after);
+}
+
+const gchar tree_ui[] =
+ "<interface>"
+ " <object class='GtkTreeStore' id='treestore1'>"
+ " <columns>"
+ " <column type='gchararray'/>"
+ " <column type='gchararray'/>"
+ " <column type='gchararray'/>"
+ " <column type='gboolean'/>"
+ " <column type='gint'/>"
+ " <column type='gint'/>"
+ " </columns>"
+ " </object>"
+ " <object class='GtkWindow' id='window1'>"
+ " <child>"
+ " <object class='GtkTreeView' id='treeview1'>"
+ " <property name='visible'>True</property>"
+ " <property name='model'>treestore1</property>"
+ " <child>"
+ " <object class='GtkTreeViewColumn' id='column1'>"
+ " <property name='title' translatable='yes'>First column</property>"
+ " <child>"
+ " <object class='GtkCellRendererText' id='renderer1'>"
+ " </object>"
+ " <attributes>"
+ " <attribute name='text'>0</attribute>"
+ " </attributes>"
+ " </child>"
+ " <child>"
+ " <object class='GtkCellRendererToggle' id='renderer2'>"
+ " </object>"
+ " <attributes>"
+ " <attribute name='active'>3</attribute>"
+ " </attributes>"
+ " </child>"
+ " </object>"
+ " </child>"
+ " <child>"
+ " <object class='GtkTreeViewColumn' id='column2'>"
+ " <property name='title' translatable='yes'>Second column</property>"
+ " <child>"
+ " <object class='GtkCellRendererText' id='renderer3'>"
+ " </object>"
+ " <attributes>"
+ " <attribute name='text'>1</attribute>"
+ " </attributes>"
+ " </child>"
+ " <child>"
+ " <object class='GtkCellRendererProgress' id='renderer4'>"
+ " </object>"
+ " <attributes>"
+ " <attribute name='value'>4</attribute>"
+ " </attributes>"
+ " </child>"
+ " </object>"
+ " </child>"
+ " </object>"
+ " </child>"
+ " </object>"
+ "</interface>";
+
+static void
+populate_tree (GtkBuilder *builder)
+{
+ GtkTreeView *tv;
+ GtkTreeStore *store;
+ GtkTreeIter iter;
+ gint i;
+
+ tv = (GtkTreeView *)gtk_builder_get_object (builder, "treeview1");
+ store = (GtkTreeStore *)gtk_tree_view_get_model (tv);
+
+ /* append a thousand rows */
+ for (i = 0; i < 333; i++)
+ {
+ gtk_tree_store_append (store, &iter, NULL);
+ gtk_tree_store_set (store, &iter, 0, "Bla", 1, "Bla bla", 2, "Bla bla bla", 3, i % 2 == 0 ? TRUE : FALSE, 4, i % 100, 5, i, -1);
+ gtk_tree_store_append (store, &iter, &iter);
+ gtk_tree_store_set (store, &iter, 0, "Bla", 1, "Bla bla", 2, "Bla bla bla", 3, i % 2 == 0 ? TRUE : FALSE, 4, i % 100, 5, i, -1);
+ gtk_tree_store_append (store, &iter, &iter);
+ gtk_tree_store_set (store, &iter, 0, "Bla", 1, "Bla bla", 2, "Bla bla bla", 3, i % 2 == 0 ? TRUE : FALSE, 4, i % 100, 5, i, -1);
+ }
+}
+
+static void
test_performance_tree (void)
{
GtkBuilder *builder;
@@ -152,7 +297,7 @@ test_performance_tree (void)
GError *error = NULL;
builder = gtk_builder_new ();
- gtk_builder_add_from_string (builder, treeui, -1, &error);
+ gtk_builder_add_from_string (builder, tree_ui, -1, &error);
g_assert_no_error (error);
window = builder_get_toplevel (builder);
g_assert (window);
@@ -179,7 +324,7 @@ test_a11y_performance_tree (void)
gint count_after;
builder = gtk_builder_new ();
- gtk_builder_add_from_string (builder, treeui, -1, &error);
+ gtk_builder_add_from_string (builder, tree_ui, -1, &error);
g_assert_no_error (error);
window = builder_get_toplevel (builder);
g_assert (window);
@@ -199,7 +344,7 @@ test_a11y_performance_tree (void)
walk_accessible_tree (gtk_widget_get_accessible (window), &count_after);
elapsed = g_test_timer_elapsed ();
- g_test_minimized_result (elapsed, "large tree test with a11y: %gsec", elapsed);
+ g_test_minimized_result (elapsed, "large tree with a11y: %gsec", elapsed);
g_object_unref (builder);
g_test_message ("%d accessibles before, %d after\n", count_before, count_after);
@@ -213,6 +358,8 @@ main (int argc, char *argv[])
if (!g_test_perf ())
return 0;
+ g_test_add_func ("/performance/list", test_performance_list);
+ g_test_add_func ("/a11y/performance/list", test_a11y_performance_list);
g_test_add_func ("/performance/tree", test_performance_tree);
g_test_add_func ("/a11y/performance/tree", test_a11y_performance_tree);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]