diff options
author | Sebastian Thiel <byronimo@gmail.com> | 2010-06-03 16:35:35 +0200 |
---|---|---|
committer | Sebastian Thiel <byronimo@gmail.com> | 2010-06-03 16:35:35 +0200 |
commit | 38d59fc8ccccae8882fa48671377bf40a27915a7 (patch) | |
tree | 84a3671b709f9fcff39819805a4902546e4d6d66 /test/git/performance/test_utils.py | |
parent | 6f8ce8901e21587cd2320562df412e05b5ab1731 (diff) | |
download | gitpython-38d59fc8ccccae8882fa48671377bf40a27915a7.tar.gz |
odb: implemented loose object streaming, which is impossible to do efficiently considering that it copies string buffers all the time
Diffstat (limited to 'test/git/performance/test_utils.py')
-rw-r--r-- | test/git/performance/test_utils.py | 44 |
1 files changed, 44 insertions, 0 deletions
diff --git a/test/git/performance/test_utils.py b/test/git/performance/test_utils.py new file mode 100644 index 00000000..381d7c8b --- /dev/null +++ b/test/git/performance/test_utils.py @@ -0,0 +1,44 @@ +"""Performance of utilities""" +from time import time +import sys +import stat + +from lib import ( + TestBigRepoReadOnly + ) + + +class TestUtilPerformance(TestBigRepoReadOnly): + + def test_access(self): + # compare dict vs. slot access + class Slotty(object): + __slots__ = "attr" + def __init__(self): + self.attr = 1 + + class Dicty(object): + def __init__(self): + self.attr = 1 + + class BigSlotty(object): + __slots__ = ('attr', ) + tuple('abcdefghijk') + def __init__(self): + for attr in self.__slots__: + setattr(self, attr, 1) + + class BigDicty(object): + def __init__(self): + for attr in BigSlotty.__slots__: + setattr(self, attr, 1) + + ni = 1000000 + for cls in (Slotty, Dicty, BigSlotty, BigDicty): + cli = cls() + st = time() + for i in xrange(ni): + cli.attr + # END for each access + elapsed = time() - st + print >> sys.stderr, "Accessed %s.attr %i times in %s s ( %f acc / s)" % (cls.__name__, ni, elapsed, ni / elapsed) + # END for each class type |