summaryrefslogtreecommitdiff
path: root/gitdb
diff options
context:
space:
mode:
authorKostis Anagnostopoulos <ankostis@gmail.com>2016-10-01 23:08:31 +0200
committerKostis Anagnostopoulos <ankostis@gmail.com>2016-10-22 04:08:26 +0200
commit587dc4ec1311e135d70996a077a2f978e303d3fc (patch)
treefe5980b960711f66ea420c38edd346af3c274211 /gitdb
parent62202bbbb58379814c44bd26cf662e68d3fa6dbb (diff)
downloadgitdb-587dc4ec1311e135d70996a077a2f978e303d3fc.tar.gz
TCs: fix div-by-zero on elapsed times (appveyor CPU is fast!)
Diffstat (limited to 'gitdb')
-rw-r--r--gitdb/test/performance/test_pack.py10
-rw-r--r--gitdb/test/performance/test_pack_streaming.py6
-rw-r--r--gitdb/test/performance/test_stream.py6
3 files changed, 11 insertions, 11 deletions
diff --git a/gitdb/test/performance/test_pack.py b/gitdb/test/performance/test_pack.py
index bdd2b0a..fc8d9d5 100644
--- a/gitdb/test/performance/test_pack.py
+++ b/gitdb/test/performance/test_pack.py
@@ -36,7 +36,7 @@ class TestPackedDBPerformance(TestBigRepoR):
sha_list = list(pdb.sha_iter())
elapsed = time() - st
ns = len(sha_list)
- print("PDB: looked up %i shas by index in %f s ( %f shas/s )" % (ns, elapsed, ns / elapsed), file=sys.stderr)
+ print("PDB: looked up %i shas by index in %f s ( %f shas/s )" % (ns, elapsed, ns / (elapsed or 1)), file=sys.stderr)
# sha lookup: best-case and worst case access
pdb_pack_info = pdb._pack_info
@@ -51,7 +51,7 @@ class TestPackedDBPerformance(TestBigRepoR):
del(pdb._entities)
pdb.entities()
print("PDB: looked up %i sha in %i packs in %f s ( %f shas/s )" %
- (ns, len(pdb.entities()), elapsed, ns / elapsed), file=sys.stderr)
+ (ns, len(pdb.entities()), elapsed, ns / (elapsed or 1)), file=sys.stderr)
# END for each random mode
# query info and streams only
@@ -62,7 +62,7 @@ class TestPackedDBPerformance(TestBigRepoR):
pdb_fun(sha)
elapsed = time() - st
print("PDB: Obtained %i object %s by sha in %f s ( %f items/s )" %
- (max_items, pdb_fun.__name__.upper(), elapsed, max_items / elapsed), file=sys.stderr)
+ (max_items, pdb_fun.__name__.upper(), elapsed, max_items / (elapsed or 1)), file=sys.stderr)
# END for each function
# retrieve stream and read all
@@ -78,7 +78,7 @@ class TestPackedDBPerformance(TestBigRepoR):
elapsed = time() - st
total_kib = total_size / 1000
print("PDB: Obtained %i streams by sha and read all bytes totallying %i KiB ( %f KiB / s ) in %f s ( %f streams/s )" %
- (max_items, total_kib, total_kib / elapsed, elapsed, max_items / elapsed), file=sys.stderr)
+ (max_items, total_kib, total_kib / (elapsed or 1), elapsed, max_items / (elapsed or 1)), file=sys.stderr)
@skip_on_travis_ci
def test_loose_correctness(self):
@@ -129,5 +129,5 @@ class TestPackedDBPerformance(TestBigRepoR):
# END for each entity
elapsed = time() - st
print("PDB: verified %i objects (crc=%i) in %f s ( %f objects/s )" %
- (count, crc, elapsed, count / elapsed), file=sys.stderr)
+ (count, crc, elapsed, count / (elapsed or 1)), file=sys.stderr)
# END for each verify mode
diff --git a/gitdb/test/performance/test_pack_streaming.py b/gitdb/test/performance/test_pack_streaming.py
index f805e59..76f0f4a 100644
--- a/gitdb/test/performance/test_pack_streaming.py
+++ b/gitdb/test/performance/test_pack_streaming.py
@@ -52,14 +52,14 @@ class TestPackStreamingPerformance(TestBigRepoR):
# END gather objects for pack-writing
elapsed = time() - st
print("PDB Streaming: Got %i streams by sha in in %f s ( %f streams/s )" %
- (ni, elapsed, ni / elapsed), file=sys.stderr)
+ (ni, elapsed, ni / (elapsed or 1)), file=sys.stderr)
st = time()
PackEntity.write_pack((pdb.stream(sha) for sha in pdb.sha_iter()), ostream.write, object_count=ni)
elapsed = time() - st
total_kb = ostream.bytes_written() / 1000
print(sys.stderr, "PDB Streaming: Wrote pack of size %i kb in %f s (%f kb/s)" %
- (total_kb, elapsed, total_kb / elapsed), sys.stderr)
+ (total_kb, elapsed, total_kb / (elapsed or 1)), sys.stderr)
@skip_on_travis_ci
def test_stream_reading(self):
@@ -82,4 +82,4 @@ class TestPackStreamingPerformance(TestBigRepoR):
elapsed = time() - st
total_kib = total_size / 1000
print(sys.stderr, "PDB Streaming: Got %i streams by sha and read all bytes totallying %i KiB ( %f KiB / s ) in %f s ( %f streams/s )" %
- (ni, total_kib, total_kib / elapsed, elapsed, ni / elapsed), sys.stderr)
+ (ni, total_kib, total_kib / (elapsed or 1), elapsed, ni / (elapsed or 1)), sys.stderr)
diff --git a/gitdb/test/performance/test_stream.py b/gitdb/test/performance/test_stream.py
index bd66b26..704f4d0 100644
--- a/gitdb/test/performance/test_stream.py
+++ b/gitdb/test/performance/test_stream.py
@@ -70,7 +70,7 @@ class TestObjDBPerformance(TestBigRepoR):
size_kib = size / 1000
print("Added %i KiB (filesize = %i KiB) of %s data to loose odb in %f s ( %f Write KiB / s)" %
- (size_kib, fsize_kib, desc, elapsed_add, size_kib / elapsed_add), file=sys.stderr)
+ (size_kib, fsize_kib, desc, elapsed_add, size_kib / (elapsed_add or 1)), file=sys.stderr)
# reading all at once
st = time()
@@ -81,7 +81,7 @@ class TestObjDBPerformance(TestBigRepoR):
stream.seek(0)
assert shadata == stream.getvalue()
print("Read %i KiB of %s data at once from loose odb in %f s ( %f Read KiB / s)" %
- (size_kib, desc, elapsed_readall, size_kib / elapsed_readall), file=sys.stderr)
+ (size_kib, desc, elapsed_readall, size_kib / (elapsed_readall or 1)), file=sys.stderr)
# reading in chunks of 1 MiB
cs = 512 * 1000
@@ -101,7 +101,7 @@ class TestObjDBPerformance(TestBigRepoR):
cs_kib = cs / 1000
print("Read %i KiB of %s data in %i KiB chunks from loose odb in %f s ( %f Read KiB / s)" %
- (size_kib, desc, cs_kib, elapsed_readchunks, size_kib / elapsed_readchunks), file=sys.stderr)
+ (size_kib, desc, cs_kib, elapsed_readchunks, size_kib / (elapsed_readchunks or 1)), file=sys.stderr)
# del db file so we keep something to do
os.remove(db_file)