Skip to content

Commit ce79835

Browse files
committed
Fixed performance pack writing tests. As they are actually depent on the database (as streams have to be decompressed, it should be redesigned to have multiple database implementations)
1 parent 56a004b commit ce79835

File tree

2 files changed

+76
-80
lines changed

2 files changed

+76
-80
lines changed
Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,83 @@
1+
# Copyright (C) 2010, 2011 Sebastian Thiel (byronimo@gmail.com) and contributors
2+
#
3+
# This module is part of GitDB and is released under
4+
# the New BSD License: http://www.opensource.org/licenses/bsd-license.php
15
from packedodb_impl import TestPurePackedODBPerformanceBase
26
from git.db.py.pack import PurePackedODB
37

8+
from git.stream import NullStream
9+
10+
from git.pack import PackEntity
11+
12+
import os
13+
import sys
14+
15+
from time import time
16+
from nose import SkipTest
17+
18+
19+
class CountedNullStream(NullStream):
20+
__slots__ = '_bw'
21+
def __init__(self):
22+
self._bw = 0
23+
24+
def bytes_written(self):
25+
return self._bw
26+
27+
def write(self, d):
28+
self._bw += NullStream.write(self, d)
29+
30+
431
class TestPurePackedODB(TestPurePackedODBPerformanceBase):
532
#{ Configuration
633
PackedODBCls = PurePackedODB
734
#} END configuration
35+
36+
def test_pack_writing(self):
37+
# see how fast we can write a pack from object streams.
38+
# This will not be fast, as we take time for decompressing the streams as well
39+
ostream = CountedNullStream()
40+
pdb = self.ropdb
41+
42+
ni = 5000
43+
count = 0
44+
total_size = 0
45+
st = time()
46+
objs = list()
47+
for sha in pdb.sha_iter():
48+
count += 1
49+
objs.append(pdb.stream(sha))
50+
if count == ni:
51+
break
52+
#END gather objects for pack-writing
53+
elapsed = time() - st
54+
print >> sys.stderr, "PDB Streaming: Got %i streams by sha in in %f s ( %f streams/s )" % (ni, elapsed, ni / elapsed)
55+
56+
st = time()
57+
PackEntity.write_pack(objs, ostream.write)
58+
elapsed = time() - st
59+
total_kb = ostream.bytes_written() / 1000
60+
print >> sys.stderr, "PDB Streaming: Wrote pack of size %i kb in %f s (%f kb/s)" % (total_kb, elapsed, total_kb/elapsed)
61+
62+
63+
def test_stream_reading(self):
64+
raise SkipTest("This test was only used for --with-profile runs")
65+
pdb = self.ropdb
66+
67+
# streaming only, meant for --with-profile runs
68+
ni = 5000
69+
count = 0
70+
pdb_stream = pdb.stream
71+
total_size = 0
72+
st = time()
73+
for sha in pdb.sha_iter():
74+
if count == ni:
75+
break
76+
stream = pdb_stream(sha)
77+
stream.read()
78+
total_size += stream.size
79+
count += 1
80+
elapsed = time() - st
81+
total_kib = total_size / 1000
82+
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)
83+

git/test/performance/test_pack_streaming.py

Lines changed: 0 additions & 80 deletions
This file was deleted.

0 commit comments

Comments
 (0)