remove profiling code and cache all trees more effectively

This commit is contained in:
Scott Chacon 2009-06-03 13:29:28 -07:00
parent b797c4f3e8
commit 65f9ead2ec
2 changed files with 8 additions and 19 deletions

View File

@ -35,28 +35,11 @@ def gclone(ui, git_url, hg_repo_path=None):
hg_repo_path += '-hg'
dest_repo = hg.repository(ui, hg_repo_path, create=True)
print dest_repo
# fetch the initial git data
git = GitHandler(dest_repo, ui)
git.remote_add('origin', git_url)
import cProfile, pstats
import lsprofcalltree
prof = cProfile.Profile()
prof = prof.runctx("git.fetch('origin')", globals(), locals())
stats = pstats.Stats(prof)
k = lsprofcalltree.KCacheGrind(prof)
data = open('/tmp/prof.kgrind', 'w+')
k.output(data)
data.close()
stats.sort_stats("cumulative") # Or cumulative
stats.print_stats(80) # 80 = how many to print
# The rest is optional.
#stats.print_callees()
#stats.print_callers()
#git.fetch('origin')
git.fetch('origin')
# checkout the tip
node = git.remote_head('origin')

View File

@ -108,6 +108,7 @@ class Repo(object):
self.path = root
self.tags = Tags(self.tagdir(), self.get_tags())
self._object_store = None
self.tree_cache = {}
def controldir(self):
"""Return the path of the control directory."""
@ -315,7 +316,12 @@ class Repo(object):
return ret
def get_object(self, sha):
return self.object_store[sha]
if sha in self.tree_cache:
return self.tree_cache[sha]
obj = self.object_store[sha]
if obj._type == 'tree':
self.tree_cache[sha] = obj
return obj
def get_parents(self, sha):
return self.commit(sha).parents