[pygobject] Add performance test for Gtk.ListStore.append



commit 91f76dd94fb0afc6888a821a31c3a4e2e053360e
Author: Martin Pitt <martinpitt gnome org>
Date:   Thu Feb 28 15:08:56 2013 +0100

    Add performance test for Gtk.ListStore.append
    
    We are going to optimize this in various ways, so let's measure it.

 tests/test_overrides_gtk.py |   14 ++++++++++++++
 1 files changed, 14 insertions(+), 0 deletions(-)
---
diff --git a/tests/test_overrides_gtk.py b/tests/test_overrides_gtk.py
index 69f0d38..aea121c 100644
--- a/tests/test_overrides_gtk.py
+++ b/tests/test_overrides_gtk.py
@@ -4,6 +4,8 @@
 
 import contextlib
 import unittest
+import time
+import sys
 
 from compathelper import _unicode, _bytes
 
@@ -1420,6 +1422,18 @@ class TestTreeModel(unittest.TestCase):
         filtered[0][1] = 'ONE'
         self.assertEqual(filtered[0][1], 'ONE')
 
+    def test_list_store_performance(self):
+        model = Gtk.ListStore(int, str)
+
+        iterations = 2000
+        start = time.clock()
+        i = iterations
+        while i > 0:
+            model.append([1, 'hello'])
+            i -= 1
+        end = time.clock()
+        sys.stderr.write('[%.0f µs/append] ' % ((end - start) * 1000000 / iterations))
+
 
 @unittest.skipUnless(Gtk, 'Gtk not available')
 class TestTreeView(unittest.TestCase):


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]