summaryrefslogtreecommitdiff
path: root/git/test/performance
diff options
context:
space:
mode:
authorSebastian Thiel <byronimo@gmail.com>2015-01-03 19:48:05 +0100
committerSebastian Thiel <byronimo@gmail.com>2015-01-03 19:48:05 +0100
commit342a0276dbf11366ae91ce28dcceddc332c97eaf (patch)
treeb3a078975579c85e4e1306777931e9f3f44f5c2d /git/test/performance
parent863a40e0d35f3ff3c3e4b5dc9ff1272e1b1783b1 (diff)
downloadgitpython-342a0276dbf11366ae91ce28dcceddc332c97eaf.tar.gz
Fixed all remaining non-performance tests
* travis configuration adjusted to hopefully work better than before Performance traversal still fails when using git-python as standard repository. It naturally wants a larger one. On travis these tests are skipped though.
Diffstat (limited to 'git/test/performance')
-rw-r--r--git/test/performance/__init__.py1
-rw-r--r--git/test/performance/lib.py49
-rw-r--r--git/test/performance/test_commit.py6
-rw-r--r--git/test/performance/test_odb.py3
-rw-r--r--git/test/performance/test_streams.py3
-rw-r--r--git/test/performance/test_utils.py8
6 files changed, 40 insertions, 30 deletions
diff --git a/git/test/performance/__init__.py b/git/test/performance/__init__.py
new file mode 100644
index 00000000..8b137891
--- /dev/null
+++ b/git/test/performance/__init__.py
@@ -0,0 +1 @@
+
diff --git a/git/test/performance/lib.py b/git/test/performance/lib.py
index 6beff617..985e3637 100644
--- a/git/test/performance/lib.py
+++ b/git/test/performance/lib.py
@@ -3,6 +3,7 @@ import os
from git.test.lib import *
import shutil
import tempfile
+import logging
from git.db import (
GitCmdObjectDB,
@@ -18,18 +19,6 @@ 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 TestBigRepoR(TestBase):
@@ -51,12 +40,19 @@ class TestBigRepoR(TestBase):
head_sha_50 = '32347c375250fd470973a5d76185cac718955fd5'
#} END invariants
- @classmethod
- def setUp(cls):
- super(TestBigRepoR, cls).setUp()
- repo_path = resolve_or_fail(k_env_git_repo)
- cls.gitrorepo = Repo(repo_path, odbt=GitCmdObjectDB)
- cls.puregitrorepo = Repo(repo_path, odbt=GitDB)
+ def setUp(self):
+ try:
+ super(TestBigRepoR, self).setUp()
+ except AttributeError:
+ pass
+
+ repo_path = os.environ.get(k_env_git_repo)
+ if repo_path is None:
+ logging.info("You can set the %s environment variable to a .git repository of your choice - defaulting to the gitpython repository", k_env_git_repo)
+ repo_path = os.path.dirname(__file__)
+ # end set some repo path
+ self.gitrorepo = Repo(repo_path, odbt=GitCmdObjectDB)
+ self.puregitrorepo = Repo(repo_path, odbt=GitDB)
class TestBigRepoRW(TestBigRepoR):
@@ -65,16 +61,17 @@ class TestBigRepoRW(TestBigRepoR):
Provides ``self.gitrwrepo`` and ``self.puregitrwrepo``"""
- @classmethod
- def setUp(cls):
- super(TestBigRepoRW, cls).setUp()
+ def setUp(self):
+ try:
+ super(TestBigRepoRW, self).setUp()
+ except AttributeError:
+ pass
dirname = tempfile.mktemp()
os.mkdir(dirname)
- cls.gitrwrepo = cls.gitrorepo.clone(dirname, shared=True, bare=True, odbt=GitCmdObjectDB)
- cls.puregitrwrepo = Repo(dirname, odbt=GitDB)
+ self.gitrwrepo = self.gitrorepo.clone(dirname, shared=True, bare=True, odbt=GitCmdObjectDB)
+ self.puregitrwrepo = Repo(dirname, odbt=GitDB)
- @classmethod
- def tearDownAll(cls):
- shutil.rmtree(cls.gitrwrepo.working_dir)
+ def tearDown(self):
+ shutil.rmtree(self.gitrwrepo.working_dir)
#} END base classes
diff --git a/git/test/performance/test_commit.py b/git/test/performance/test_commit.py
index c988d160..a8f63f95 100644
--- a/git/test/performance/test_commit.py
+++ b/git/test/performance/test_commit.py
@@ -8,6 +8,7 @@ from lib import *
from git import *
from gitdb import IStream
from git.test.test_commit import assert_commit_serialization
+from gitdb.test.lib import skip_on_travis_ci
from cStringIO import StringIO
from time import time
import sys
@@ -28,6 +29,7 @@ class TestPerformance(TestBigRepoRW):
c.message
c.parents
+ @skip_on_travis_ci
def test_iteration(self):
no = 0
nc = 0
@@ -49,6 +51,7 @@ class TestPerformance(TestBigRepoRW):
print >> sys.stderr, "Traversed %i Trees and a total of %i unchached objects in %s [s] ( %f objs/s )" % (
nc, no, elapsed_time, no / elapsed_time)
+ @skip_on_travis_ci
def test_commit_traversal(self):
# bound to cat-file parsing performance
nc = 0
@@ -60,6 +63,7 @@ class TestPerformance(TestBigRepoRW):
elapsed_time = time() - st
print >> sys.stderr, "Traversed %i Commits in %s [s] ( %f commits/s )" % (nc, elapsed_time, nc / elapsed_time)
+ @skip_on_travis_ci
def test_commit_iteration(self):
# bound to stream parsing performance
nc = 0
@@ -71,6 +75,7 @@ class TestPerformance(TestBigRepoRW):
elapsed_time = time() - st
print >> sys.stderr, "Iterated %i Commits in %s [s] ( %f commits/s )" % (nc, elapsed_time, nc / elapsed_time)
+ @skip_on_travis_ci
def test_commit_serialization(self):
assert_commit_serialization(self.gitrwrepo, self.head_sha_2k, True)
@@ -80,7 +85,6 @@ class TestPerformance(TestBigRepoRW):
# serialization is probably limited on IO
hc = rwrepo.commit(self.head_sha_2k)
- commits = list()
nc = 5000
st = time()
for i in xrange(nc):
diff --git a/git/test/performance/test_odb.py b/git/test/performance/test_odb.py
index 6696e459..1c4bd9ed 100644
--- a/git/test/performance/test_odb.py
+++ b/git/test/performance/test_odb.py
@@ -2,7 +2,7 @@
from time import time
import sys
-import stat
+from gitdb.test.lib import skip_on_travis_ci
from lib import (
TestBigRepoR
@@ -11,6 +11,7 @@ from lib import (
class TestObjDBPerformance(TestBigRepoR):
+ @skip_on_travis_ci
def test_random_access(self):
results = [["Iterate Commits"], ["Iterate Blobs"], ["Retrieve Blob Data"]]
for repo in (self.gitrorepo, self.puregitrorepo):
diff --git a/git/test/performance/test_streams.py b/git/test/performance/test_streams.py
index 7800144d..a2bca94c 100644
--- a/git/test/performance/test_streams.py
+++ b/git/test/performance/test_streams.py
@@ -3,11 +3,11 @@
from git.test.lib import *
from gitdb import *
from gitdb.util import bin_to_hex
+from gitdb.test.lib import skip_on_travis_ci
from time import time
import os
import sys
-import stat
import subprocess
from gitdb.test.lib import make_memory_file
@@ -22,6 +22,7 @@ class TestObjDBPerformance(TestBigRepoR):
large_data_size_bytes = 1000 * 1000 * 10 # some MiB should do it
moderate_data_size_bytes = 1000 * 1000 * 1 # just 1 MiB
+ @skip_on_travis_ci
@with_rw_repo('HEAD', bare=True)
def test_large_data_streaming(self, rwrepo):
# TODO: This part overlaps with the same file in gitdb.test.performance.test_stream
diff --git a/git/test/performance/test_utils.py b/git/test/performance/test_utils.py
index 7db972f7..b0d6fa48 100644
--- a/git/test/performance/test_utils.py
+++ b/git/test/performance/test_utils.py
@@ -1,7 +1,8 @@
"""Performance of utilities"""
from time import time
import sys
-import stat
+
+from gitdb.test.lib import skip_on_travis_ci
from lib import (
TestBigRepoR
@@ -10,6 +11,7 @@ from lib import (
class TestUtilPerformance(TestBigRepoR):
+ @skip_on_travis_ci
def test_access(self):
# compare dict vs. slot access
class Slotty(object):
@@ -64,6 +66,7 @@ class TestUtilPerformance(TestBigRepoR):
cls.__name__, na, elapsed, na / elapsed)
# END for each sequence
+ @skip_on_travis_ci
def test_instantiation(self):
ni = 100000
max_num_items = 4
@@ -106,6 +109,7 @@ class TestUtilPerformance(TestBigRepoR):
elapsed = time() - st
print >> sys.stderr, "Created %i tuples tuple((1,2,3,4)) in %f s ( %f tuples / s)" % (ni, elapsed, ni / elapsed)
+ @skip_on_travis_ci
def test_unpacking_vs_indexing(self):
ni = 1000000
list_items = [1, 2, 3, 4]
@@ -137,6 +141,7 @@ class TestUtilPerformance(TestBigRepoR):
ni, type(sequence).__name__, len(sequence), elapsed, ni / elapsed)
# END for each sequence
+ @skip_on_travis_ci
def test_large_list_vs_iteration(self):
# what costs more: alloc/realloc of lists, or the cpu strain of iterators ?
def slow_iter(ni):
@@ -161,6 +166,7 @@ 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
+ @skip_on_travis_ci
def test_type_vs_inst_class(self):
class NewType(object):
pass