Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork966
Expand file tree
/
Copy pathtest_odb.py
More file actions
88 lines (77 loc) · 2.92 KB
/
test_odb.py
File metadata and controls
88 lines (77 loc) · 2.92 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
# This module is part of GitPython and is released under the
# 3-Clause BSD License: https://opensource.org/license/bsd-3-clause/
"""Performance tests for object store."""
importsys
fromtimeimporttime
fromtest.performance.libimportTestBigRepoR
classTestObjDBPerformance(TestBigRepoR):
deftest_random_access(self):
results= [["Iterate Commits"], ["Iterate Blobs"], ["Retrieve Blob Data"]]
forrepoin (self.gitrorepo,self.puregitrorepo):
# GET COMMITS
st=time()
root_commit=repo.commit(repo.head)
commits=list(root_commit.traverse())
nc=len(commits)
elapsed=time()-st
print(
"%s: Retrieved %i commits from ObjectStore in %g s ( %f commits / s )"
% (type(repo.odb),nc,elapsed,nc/elapsed),
file=sys.stderr,
)
results[0].append(elapsed)
# GET TREES
# Walk all trees of all commits.
st=time()
blobs_per_commit= []
nt=0
forcommitincommits:
tree=commit.tree
blobs= []
foritemintree.traverse():
nt+=1
ifitem.type=="blob":
blobs.append(item)
# Direct access for speed.
# END while trees are there for walking
blobs_per_commit.append(blobs)
# END for each commit
elapsed=time()-st
print(
"%s: Retrieved %i objects from %i commits in %g s ( %f objects / s )"
% (type(repo.odb),nt,len(commits),elapsed,nt/elapsed),
file=sys.stderr,
)
results[1].append(elapsed)
# GET BLOBS
st=time()
nb=0
too_many=15000
data_bytes=0
forblob_listinblobs_per_commit:
forblobinblob_list:
data_bytes+=len(blob.data_stream.read())
# END for each blobsha
nb+=len(blob_list)
ifnb>too_many:
break
# END for each bloblist
elapsed=time()-st
msg="%s: Retrieved %i blob (%i KiB) and their data in %g s ( %f blobs / s, %f KiB / s )"% (
type(repo.odb),
nb,
data_bytes/1000,
elapsed,
nb/elapsed,
(data_bytes/1000)/elapsed,
)
print(msg,file=sys.stderr)
results[2].append(elapsed)
# END for each repo type
# Final results.
fortest_name,a,binresults:
print(
"%s: %f s vs %f s, pure is %f times slower"% (test_name,a,b,b/a),
file=sys.stderr,
)
# END for each result