summaryrefslogtreecommitdiff
path: root/test/git/performance/test_utils.py
diff options
context:
space:
mode:
authorSebastian Thiel <byronimo@gmail.com>2010-07-14 14:27:27 +0200
committerSebastian Thiel <byronimo@gmail.com>2010-07-14 14:27:27 +0200
commit24740f22c59c3bcafa7b2c1f2ec997e4e14f3615 (patch)
treefa00faeb04676b63cd41f15ffd148090b9a03cdf /test/git/performance/test_utils.py
parentbcd37b68533d0cceb7e73dd1ed1428fa09f7dc17 (diff)
downloadgitpython-24740f22c59c3bcafa7b2c1f2ec997e4e14f3615.tar.gz
Added performance test to compare inst.__class__() vs type(inst)() class. The first one is faster, although I would have expected the latter one to be faster
Diffstat (limited to 'test/git/performance/test_utils.py')
-rw-r--r--test/git/performance/test_utils.py21
1 files changed, 21 insertions, 0 deletions
diff --git a/test/git/performance/test_utils.py b/test/git/performance/test_utils.py
index 16100f8b..19c1e84a 100644
--- a/test/git/performance/test_utils.py
+++ b/test/git/performance/test_utils.py
@@ -151,3 +151,24 @@ class TestUtilPerformance(TestBigRepoR):
print >> sys.stderr, "Iterated %i items from iterator in %f s ( %f acc / s)" % (ni, elapsed, ni / elapsed)
# END for each number of iterations
+ def test_type_vs_inst_class(self):
+ class NewType(object):
+ pass
+
+ # lets see which way is faster
+ inst = NewType()
+
+ ni = 1000000
+ st = time()
+ for i in xrange(ni):
+ inst.__class__()
+ # END for each item
+ elapsed = time() - st
+ print >> sys.stderr, "Created %i items using inst.__class__ in %f s ( %f items / s)" % (ni, elapsed, ni / elapsed)
+
+ st = time()
+ for i in xrange(ni):
+ type(inst)()
+ # END for each item
+ elapsed = time() - st
+ print >> sys.stderr, "Created %i items using type(inst)() in %f s ( %f items / s)" % (ni, elapsed, ni / elapsed)