| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent bffc537 commit 30f49d9
3 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1,8 +1,10 @@ | |||
| 1 | - # test_performance.py | ||
| 2 | 1 | # Copyright (C) 2008, 2009 Michael Trier (mtrier@gmail.com) and contributors | |
| 3 | 2 | # | |
| 4 | 3 | # This module is part of GitPython and is released under | |
| 5 | 4 | # the BSD License: https://opensource.org/license/bsd-3-clause/ | |
| 5 | + | ||
| 6 | + """Performance tests for commits (iteration, traversal, and serialization).""" | ||
| 7 | + | ||
| 6 | 8 | from io import BytesIO | |
| 7 | 9 | from time import time | |
| 8 | 10 | import sys | |
@@ -19,7 +21,7 @@ def tearDown(self): | |||
| 19 | 21 | ||
| 20 | 22 | gc.collect() | |
| 21 | 23 | ||
| 22 | - # ref with about 100 commits in its history | ||
| 24 | + # ref with about 100 commits in its history. | ||
| 23 | 25 | ref_100 = "0.1.6" | |
| 24 | 26 | ||
| 25 | 27 | def _query_commit_info(self, c): | |
@@ -36,9 +38,9 @@ def test_iteration(self): | |||
| 36 | 38 | no = 0 | |
| 37 | 39 | nc = 0 | |
| 38 | 40 | ||
| 39 | - # find the first commit containing the given path - always do a full | ||
| 40 | - # iteration ( restricted to the path in question ), but in fact it should | ||
| 41 | - # return quite a lot of commits, we just take one and hence abort the operation | ||
| 41 | + # Find the first commit containing the given path. Always do a full iteration | ||
| 42 | + # (restricted to the path in question). This should return quite a lot of | ||
| 43 | + # commits. We just take one and hence abort the operation. | ||
| 42 | 44 | ||
| 43 | 45 | st = time() | |
| 44 | 46 | for c in self.rorepo.iter_commits(self.ref_100): | |
@@ -57,7 +59,7 @@ def test_iteration(self): | |||
| 57 | 59 | ) | |
| 58 | 60 | ||
| 59 | 61 | def test_commit_traversal(self): | |
| 60 | - # bound to cat-file parsing performance | ||
| 62 | + # Bound to cat-file parsing performance. | ||
| 61 | 63 | nc = 0 | |
| 62 | 64 | st = time() | |
| 63 | 65 | for c in self.gitrorepo.commit().traverse(branch_first=False): | |
@@ -71,7 +73,7 @@ def test_commit_traversal(self): | |||
| 71 | 73 | ) | |
| 72 | 74 | ||
| 73 | 75 | def test_commit_iteration(self): | |
| 74 | - # bound to stream parsing performance | ||
| 76 | + # Bound to stream parsing performance. | ||
| 75 | 77 | nc = 0 | |
| 76 | 78 | st = time() | |
| 77 | 79 | for c in Commit.iter_items(self.gitrorepo, self.gitrorepo.head): | |
@@ -89,8 +91,8 @@ def test_commit_serialization(self): | |||
| 89 | 91 | ||
| 90 | 92 | rwrepo = self.gitrwrepo | |
| 91 | 93 | make_object = rwrepo.odb.store | |
| 92 | - # direct serialization - deserialization can be tested afterwards | ||
| 93 | - # serialization is probably limited on IO | ||
| 94 | + # Direct serialization - deserialization can be tested afterwards. | ||
| 95 | + # Serialization is probably limited on IO. | ||
| 94 | 96 | hc = rwrepo.commit(rwrepo.head) | |
| 95 | 97 | ||
| 96 | 98 | nc = 5000 | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1,4 +1,5 @@ | |||
| 1 | - """Performance tests for object store""" | ||
| 1 | + """Performance tests for object store.""" | ||
| 2 | + | ||
| 2 | 3 | import sys | |
| 3 | 4 | from time import time | |
| 4 | 5 | ||
@@ -24,7 +25,7 @@ def test_random_access(self): | |||
| 24 | 25 | results[0].append(elapsed) | |
| 25 | 26 | ||
| 26 | 27 | # GET TREES | |
| 27 | - # walk all trees of all commits | ||
| 28 | + # Walk all trees of all commits. | ||
| 28 | 29 | st = time() | |
| 29 | 30 | blobs_per_commit = [] | |
| 30 | 31 | nt = 0 | |
@@ -35,7 +36,7 @@ def test_random_access(self): | |||
| 35 | 36 | nt += 1 | |
| 36 | 37 | if item.type == "blob": | |
| 37 | 38 | blobs.append(item) | |
| 38 | - # direct access for speed | ||
| 39 | + # Direct access for speed. | ||
| 39 | 40 | # END while trees are there for walking | |
| 40 | 41 | blobs_per_commit.append(blobs) | |
| 41 | 42 | # END for each commit | |
@@ -75,7 +76,7 @@ def test_random_access(self): | |||
| 75 | 76 | results[2].append(elapsed) | |
| 76 | 77 | # END for each repo type | |
| 77 | 78 | ||
| 78 | - # final results | ||
| 79 | + # Final results. | ||
| 79 | 80 | for test_name, a, b in results: | |
| 80 | 81 | print( | |
| 81 | 82 | "%s: %f s vs %f s, pure is %f times slower" % (test_name, a, b, b / a), | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1,4 +1,5 @@ | |||
| 1 | - """Performance data streaming performance""" | ||
| 1 | + """Performance tests for data streaming.""" | ||
| 2 | + | ||
| 2 | 3 | import os | |
| 3 | 4 | import subprocess | |
| 4 | 5 | import sys | |
@@ -15,13 +16,13 @@ | |||
| 15 | 16 | ||
| 16 | 17 | ||
| 17 | 18 | class TestObjDBPerformance(TestBigRepoR): | |
| 18 | - large_data_size_bytes = 1000 * 1000 * 10 # some MiB should do it | ||
| 19 | - moderate_data_size_bytes = 1000 * 1000 * 1 # just 1 MiB | ||
| 19 | + large_data_size_bytes = 1000 * 1000 * 10 # Some MiB should do it. | ||
| 20 | + moderate_data_size_bytes = 1000 * 1000 * 1 # Just 1 MiB. | ||
| 20 | 21 | ||
| 21 | 22 | @with_rw_repo("HEAD", bare=True) | |
| 22 | 23 | def test_large_data_streaming(self, rwrepo): | |
| 23 | - # TODO: This part overlaps with the same file in gitdb.test.performance.test_stream | ||
| 24 | - # It should be shared if possible | ||
| 24 | + # TODO: This part overlaps with the same file in gitdb.test.performance.test_stream. | ||
| 25 | + # It should be shared if possible. | ||
| 25 | 26 | ldb = LooseObjectDB(osp.join(rwrepo.git_dir, "objects")) | |
| 26 | 27 | ||
| 27 | 28 | for randomize in range(2): | |
@@ -32,7 +33,7 @@ def test_large_data_streaming(self, rwrepo): | |||
| 32 | 33 | elapsed = time() - st | |
| 33 | 34 | print("Done (in %f s)" % elapsed, file=sys.stderr) | |
| 34 | 35 | ||
| 35 | - # writing - due to the compression it will seem faster than it is | ||
| 36 | + # Writing - due to the compression it will seem faster than it is. | ||
| 36 | 37 | st = time() | |
| 37 | 38 | binsha = ldb.store(IStream("blob", size, stream)).binsha | |
| 38 | 39 | elapsed_add = time() - st | |
@@ -45,7 +46,7 @@ def test_large_data_streaming(self, rwrepo): | |||
| 45 | 46 | msg %= (size_kib, fsize_kib, desc, elapsed_add, size_kib / elapsed_add) | |
| 46 | 47 | print(msg, file=sys.stderr) | |
| 47 | 48 | ||
| 48 | - # reading all at once | ||
| 49 | + # Reading all at once. | ||
| 49 | 50 | st = time() | |
| 50 | 51 | ostream = ldb.stream(binsha) | |
| 51 | 52 | shadata = ostream.read() | |
@@ -57,7 +58,7 @@ def test_large_data_streaming(self, rwrepo): | |||
| 57 | 58 | msg %= (size_kib, desc, elapsed_readall, size_kib / elapsed_readall) | |
| 58 | 59 | print(msg, file=sys.stderr) | |
| 59 | 60 | ||
| 60 | - # reading in chunks of 1 MiB | ||
| 61 | + # Reading in chunks of 1 MiB. | ||
| 61 | 62 | cs = 512 * 1000 | |
| 62 | 63 | chunks = [] | |
| 63 | 64 | st = time() | |
@@ -86,7 +87,7 @@ def test_large_data_streaming(self, rwrepo): | |||
| 86 | 87 | file=sys.stderr, | |
| 87 | 88 | ) | |
| 88 | 89 | ||
| 89 | - # del db file so git has something to do | ||
| 90 | + # del db file so git has something to do. | ||
| 90 | 91 | ostream = None | |
| 91 | 92 | import gc | |
| 92 | 93 | ||
@@ -95,34 +96,34 @@ def test_large_data_streaming(self, rwrepo): | |||
| 95 | 96 | ||
| 96 | 97 | # VS. CGIT | |
| 97 | 98 | ########## | |
| 98 | - # CGIT ! Can using the cgit programs be faster ? | ||
| 99 | + # CGIT! Can using the cgit programs be faster? | ||
| 99 | 100 | proc = rwrepo.git.hash_object("-w", "--stdin", as_process=True, istream=subprocess.PIPE) | |
| 100 | 101 | ||
| 101 | - # write file - pump everything in at once to be a fast as possible | ||
| 102 | - data = stream.getvalue() # cache it | ||
| 102 | + # Write file - pump everything in at once to be a fast as possible. | ||
| 103 | + data = stream.getvalue() # Cache it. | ||
| 103 | 104 | st = time() | |
| 104 | 105 | proc.stdin.write(data) | |
| 105 | 106 | proc.stdin.close() | |
| 106 | 107 | gitsha = proc.stdout.read().strip() | |
| 107 | 108 | proc.wait() | |
| 108 | 109 | gelapsed_add = time() - st | |
| 109 | 110 | del data | |
| 110 | - assert gitsha == bin_to_hex(binsha) # we do it the same way, right ? | ||
| 111 | + assert gitsha == bin_to_hex(binsha) # We do it the same way, right? | ||
| 111 | 112 | ||
| 112 | - # as its the same sha, we reuse our path | ||
| 113 | + # As it's the same sha, we reuse our path. | ||
| 113 | 114 | fsize_kib = osp.getsize(db_file) / 1000 | |
| 114 | 115 | msg = "Added %i KiB (filesize = %i KiB) of %s data to using git-hash-object in %f s ( %f Write KiB / s)" | |
| 115 | 116 | msg %= (size_kib, fsize_kib, desc, gelapsed_add, size_kib / gelapsed_add) | |
| 116 | 117 | print(msg, file=sys.stderr) | |
| 117 | 118 | ||
| 118 | - # compare ... | ||
| 119 | + # Compare. | ||
| 119 | 120 | print( | |
| 120 | 121 | "Git-Python is %f %% faster than git when adding big %s files" | |
| 121 | 122 | % (100.0 - (elapsed_add / gelapsed_add) * 100, desc), | |
| 122 | 123 | file=sys.stderr, | |
| 123 | 124 | ) | |
| 124 | 125 | ||
| 125 | - # read all | ||
| 126 | + # Read all. | ||
| 126 | 127 | st = time() | |
| 127 | 128 | _hexsha, _typename, size, data = rwrepo.git.get_object_data(gitsha) | |
| 128 | 129 | gelapsed_readall = time() - st | |
@@ -132,14 +133,14 @@ def test_large_data_streaming(self, rwrepo): | |||
| 132 | 133 | file=sys.stderr, | |
| 133 | 134 | ) | |
| 134 | 135 | ||
| 135 | - # compare | ||
| 136 | + # Compare. | ||
| 136 | 137 | print( | |
| 137 | 138 | "Git-Python is %f %% faster than git when reading big %sfiles" | |
| 138 | 139 | % (100.0 - (elapsed_readall / gelapsed_readall) * 100, desc), | |
| 139 | 140 | file=sys.stderr, | |
| 140 | 141 | ) | |
| 141 | 142 | ||
| 142 | - # read chunks | ||
| 143 | + # Read chunks. | ||
| 143 | 144 | st = time() | |
| 144 | 145 | _hexsha, _typename, size, stream = rwrepo.git.stream_object_data(gitsha) | |
| 145 | 146 | while True: | |
@@ -158,7 +159,7 @@ def test_large_data_streaming(self, rwrepo): | |||
| 158 | 159 | ) | |
| 159 | 160 | print(msg, file=sys.stderr) | |
| 160 | 161 | ||
| 161 | - # compare | ||
| 162 | + # Compare. | ||
| 162 | 163 | print( | |
| 163 | 164 | "Git-Python is %f %% faster than git when reading big %s files in chunks" | |
| 164 | 165 | % (100.0 - (elapsed_readchunks / gelapsed_readchunks) * 100, desc), | |
| Back | FazBrowse Home | New Git URL |
0 commit comments