mirror of
https://github.com/facebook/sapling.git
synced 2024-10-10 08:47:12 +03:00
remove profiling code and cache all trees more effectively
This commit is contained in:
parent
b797c4f3e8
commit
65f9ead2ec
19
__init__.py
19
__init__.py
@ -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')
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user