From 4e1c89ec97ec90037583e85d0e9e71e9c845a19b Mon Sep 17 00:00:00 2001 From: Sebastian Thiel Date: Wed, 2 Jun 2010 16:13:32 +0200 Subject: Added performance testing foundation library, reworked existing performance tests to work on larger repositories --- test/git/performance/lib.py | 46 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) create mode 100644 test/git/performance/lib.py (limited to 'test/git/performance/lib.py') diff --git a/test/git/performance/lib.py b/test/git/performance/lib.py new file mode 100644 index 00000000..4b552b20 --- /dev/null +++ b/test/git/performance/lib.py @@ -0,0 +1,46 @@ +"""Contains library functions""" +import os +from test.testlib import * + +from git import ( + Repo + ) + +#{ Invvariants +k_env_git_repo = "GIT_PYTHON_TEST_GIT_REPO_BASE" +#} END invariants + + +#{ Utilities +def resolve_or_fail(env_var): + """:return: resolved environment variable or raise EnvironmentError""" + try: + return os.environ[env_var] + except KeyError: + raise EnvironmentError("Please set the %r envrionment variable and retry" % env_var) + # END exception handling + +#} END utilities + + +#{ Base Classes + +class TestBigRepoReadOnly(TestBase): + """TestCase providing access to readonly 'big' repositories using the following + member variables: + + * gitrepo + + * Read-Only git repository - actually the repo of git itself""" + + #{ Invariants + head_sha_2k = '235d521da60e4699e5bd59ac658b5b48bd76ddca' + head_sha_50 = '32347c375250fd470973a5d76185cac718955fd5' + #} END invariants + + @classmethod + def setUpAll(cls): + super(TestBigRepoReadOnly, cls).setUpAll() + cls.gitrepo = Repo(resolve_or_fail(k_env_git_repo)) + +#} END base classes -- cgit v1.2.1 From 1e2b46138ba58033738a24dadccc265748fce2ca Mon Sep 17 00:00:00 2001 From: Sebastian Thiel Date: Thu, 3 Jun 2010 23:20:34 +0200 Subject: commit.create_from_tree now uses pure python implementation, fixed message parsing which truncated newlines although it was ilegitimate. Its up to the reader to truncate therse, nowhere in the git code I could find anyone adding newlines to commits where it is written Added performance tests for serialization, it does about 5k commits per second if writing to tmpfs --- test/git/performance/lib.py | 25 ++++++++++++++++++++++--- 1 file changed, 22 insertions(+), 3 deletions(-) (limited to 'test/git/performance/lib.py') diff --git a/test/git/performance/lib.py b/test/git/performance/lib.py index 4b552b20..650bea82 100644 --- a/test/git/performance/lib.py +++ b/test/git/performance/lib.py @@ -1,6 +1,8 @@ """Contains library functions""" import os from test.testlib import * +import shutil +import tempfile from git import ( Repo @@ -25,7 +27,7 @@ def resolve_or_fail(env_var): #{ Base Classes -class TestBigRepoReadOnly(TestBase): +class TestBigRepoR(TestBase): """TestCase providing access to readonly 'big' repositories using the following member variables: @@ -40,7 +42,24 @@ class TestBigRepoReadOnly(TestBase): @classmethod def setUpAll(cls): - super(TestBigRepoReadOnly, cls).setUpAll() - cls.gitrepo = Repo(resolve_or_fail(k_env_git_repo)) + super(TestBigRepoR, cls).setUpAll() + cls.gitrorepo = Repo(resolve_or_fail(k_env_git_repo)) + +class TestBigRepoRW(TestBigRepoR): + """As above, but provides a big repository that we can write to. + + Provides ``self.gitrwrepo``""" + + @classmethod + def setUpAll(cls): + super(TestBigRepoRW, cls).setUpAll() + dirname = tempfile.mktemp() + os.mkdir(dirname) + cls.gitrwrepo = cls.gitrorepo.clone(dirname, shared=True, bare=True) + + @classmethod + def tearDownAll(cls): + shutil.rmtree(cls.gitrwrepo.working_tree_dir) + #} END base classes -- cgit v1.2.1 From 1906ee4df9ae4e734288c5203cf79894dff76cab Mon Sep 17 00:00:00 2001 From: Sebastian Thiel Date: Thu, 3 Jun 2010 23:27:09 +0200 Subject: Fixed compatability issues with python 2.5, made sure all tests run --- test/git/performance/lib.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'test/git/performance/lib.py') diff --git a/test/git/performance/lib.py b/test/git/performance/lib.py index 650bea82..7d2a9f4a 100644 --- a/test/git/performance/lib.py +++ b/test/git/performance/lib.py @@ -60,6 +60,6 @@ class TestBigRepoRW(TestBigRepoR): @classmethod def tearDownAll(cls): - shutil.rmtree(cls.gitrwrepo.working_tree_dir) + shutil.rmtree(cls.gitrwrepo.working_dir) #} END base classes -- cgit v1.2.1