summaryrefslogtreecommitdiff
path: root/test/git/async/test_performance.py
diff options
context:
space:
mode:
authorSebastian Thiel <byronimo@gmail.com>2010-06-11 20:13:21 +0200
committerSebastian Thiel <byronimo@gmail.com>2010-06-11 20:13:21 +0200
commita28942bdf01f4ddb9d0b5a0489bd6f4e101dd775 (patch)
tree1e8b49f048a8bb88787d5cc25bae5f278e05b9a6 /test/git/async/test_performance.py
parentcac6e06cc9ef2903a15e594186445f3baa989a1a (diff)
downloadgitpython-a28942bdf01f4ddb9d0b5a0489bd6f4e101dd775.tar.gz
Added performance test, improved iterator task which will now be usable by default. It shows that there must be the notion of a producer, which can work if there are no items read
Diffstat (limited to 'test/git/async/test_performance.py')
-rw-r--r--test/git/async/test_performance.py51
1 files changed, 51 insertions, 0 deletions
diff --git a/test/git/async/test_performance.py b/test/git/async/test_performance.py
new file mode 100644
index 00000000..896d230e
--- /dev/null
+++ b/test/git/async/test_performance.py
@@ -0,0 +1,51 @@
+"""Channel testing"""
+from test.testlib import *
+from task import *
+
+from git.async.pool import *
+from git.async.thread import terminate_threads
+from git.async.util import cpu_count
+
+import time
+import sys
+
+
+
+class TestThreadPoolPerformance(TestBase):
+
+ max_threads = cpu_count()
+
+ def test_base(self):
+ # create a dependency network, and see how the performance changes
+ # when adjusting the amount of threads
+ pool = ThreadPool(0)
+ ni = 1000 # number of items to process
+ print self.max_threads
+ for num_threads in range(self.max_threads*2 + 1):
+ pool.set_size(num_threads)
+ for num_transformers in (1, 5, 10):
+ for read_mode in range(2):
+ ts, rcs = add_task_chain(pool, ni, count=num_transformers,
+ feedercls=InputIteratorThreadTask,
+ transformercls=TestThreadPerformanceTaskNode,
+ include_verifier=False)
+
+ mode_info = "read(0)"
+ if read_mode == 1:
+ mode_info = "read(1) * %i" % ni
+ # END mode info
+ fmt = "Threadcount=%%i: Produced %%i items using %s in %%i transformations in %%f s (%%f items / s)" % mode_info
+ reader = rcs[-1]
+ st = time.time()
+ if read_mode == 1:
+ for i in xrange(ni):
+ assert len(reader.read(1)) == 1
+ # END for each item to read
+ else:
+ assert len(reader.read(0)) == ni
+ # END handle read mode
+ elapsed = time.time() - st
+ print >> sys.stderr, fmt % (num_threads, ni, num_transformers, elapsed, ni / elapsed)
+ # END for each read-mode
+ # END for each amount of processors
+ # END for each thread count