##// END OF EJS Templates
hgweb: profile HTTP requests...
hgweb: profile HTTP requests Currently, running `hg serve --profile` doesn't yield anything useful: when the process is terminated the profiling output displays results from the main thread, which typically spends most of its time in select.select(). Furthermore, it has no meaningful results from mercurial.* modules because the threads serving HTTP requests don't actually get profiled. This patch teaches the hgweb wsgi applications to profile individual requests. If profiling is enabled, the profiler kicks in after HTTP/WSGI environment processing but before Mercurial's main request processing. The profile results are printed to the configured profiling output. If running `hg serve` from a shell, they will be printed to stderr, just before the HTTP request line is logged. If profiling to a file, we only write a single profile to the file because the file is not opened in append mode. We could add support for appending to files in a future patch if someone wants it. Per request profiling doesn't work with the statprof profiler because internally that profiler collects samples from the thread that *initially* requested profiling be enabled. I have plans to address this by vendoring Facebook's customized statprof and then improving it.

File last commit:

r28842:d466facc default
r29787:80df0426 default
Show More
test-revlog-ancestry.py
88 lines | 1.9 KiB | text/x-python | PythonLexer
/ tests / test-revlog-ancestry.py
Robert Stanca
py3: use print_function in test-revlog-ancestry.py
r28764 from __future__ import absolute_import, print_function
Stefano Tortarolo
Add ancestors and descendants to revlog...
r6872 import os
Robert Stanca
py3: use absolute_import in test-revlog-ancestry.py
r28763 from mercurial import (
hg,
merge,
Yuya Nishihara
tests: alias ui as uimod in test-revlog-ancestry/test-ui-verbosity
r28842 ui as uimod,
Robert Stanca
py3: use absolute_import in test-revlog-ancestry.py
r28763 )
Stefano Tortarolo
Add ancestors and descendants to revlog...
r6872
Yuya Nishihara
tests: alias ui as uimod in test-revlog-ancestry/test-ui-verbosity
r28842 u = uimod.ui()
Stefano Tortarolo
Add ancestors and descendants to revlog...
r6872
repo = hg.repository(u, 'test1', create=1)
os.chdir('test1')
def commit(text, time):
repo.commit(text=text, date="%d 0" % time)
def addcommit(name, time):
Alejandro Santos
compat: use open() instead of file() everywhere
r9031 f = open(name, 'w')
Stefano Tortarolo
Add ancestors and descendants to revlog...
r6872 f.write('%s\n' % name)
f.close()
Dirkjan Ochtman
move working dir/dirstate methods from localrepo to workingctx
r11303 repo[None].add([name])
Stefano Tortarolo
Add ancestors and descendants to revlog...
r6872 commit(name, time)
def update(rev):
Augie Fackler
merge: have merge.update use a matcher instead of partial fn...
r27344 merge.update(repo, rev, False, True)
Stefano Tortarolo
Add ancestors and descendants to revlog...
r6872
def merge_(rev):
Augie Fackler
merge: have merge.update use a matcher instead of partial fn...
r27344 merge.update(repo, rev, True, False)
Stefano Tortarolo
Add ancestors and descendants to revlog...
r6872
if __name__ == '__main__':
addcommit("A", 0)
addcommit("B", 1)
update(0)
addcommit("C", 2)
merge_(1)
commit("D", 3)
update(2)
addcommit("E", 4)
addcommit("F", 5)
update(3)
addcommit("G", 6)
merge_(5)
commit("H", 7)
update(5)
addcommit("I", 8)
# Ancestors
Robert Stanca
py3: use print_function in test-revlog-ancestry.py
r28764 print('Ancestors of 5')
Bryan O'Sullivan
revlog: ancestors(*revs) becomes ancestors(revs) (API)...
r16866 for r in repo.changelog.ancestors([5]):
Robert Stanca
py3: use print_function in test-revlog-ancestry.py
r28764 print(r, end=' ')
Stefano Tortarolo
Add ancestors and descendants to revlog...
r6872
Robert Stanca
py3: use print_function in test-revlog-ancestry.py
r28764 print('\nAncestors of 6 and 5')
Bryan O'Sullivan
revlog: ancestors(*revs) becomes ancestors(revs) (API)...
r16866 for r in repo.changelog.ancestors([6, 5]):
Robert Stanca
py3: use print_function in test-revlog-ancestry.py
r28764 print(r, end=' ')
Stefano Tortarolo
Add ancestors and descendants to revlog...
r6872
Robert Stanca
py3: use print_function in test-revlog-ancestry.py
r28764 print('\nAncestors of 5 and 4')
Bryan O'Sullivan
revlog: ancestors(*revs) becomes ancestors(revs) (API)...
r16866 for r in repo.changelog.ancestors([5, 4]):
Robert Stanca
py3: use print_function in test-revlog-ancestry.py
r28764 print(r, end=' ')
Stefano Tortarolo
Add ancestors and descendants to revlog...
r6872
Robert Stanca
py3: use print_function in test-revlog-ancestry.py
r28764 print('\nAncestors of 7, stop at 6')
Joshua Redstone
revlog: add optional stoprev arg to revlog.ancestors()...
r16868 for r in repo.changelog.ancestors([7], 6):
Robert Stanca
py3: use print_function in test-revlog-ancestry.py
r28764 print(r, end=' ')
Joshua Redstone
revlog: add optional stoprev arg to revlog.ancestors()...
r16868
Robert Stanca
py3: use print_function in test-revlog-ancestry.py
r28764 print('\nAncestors of 7, including revs')
Siddharth Agarwal
revlog.ancestors: add support for including revs...
r18081 for r in repo.changelog.ancestors([7], inclusive=True):
Robert Stanca
py3: use print_function in test-revlog-ancestry.py
r28764 print(r, end=' ')
Siddharth Agarwal
revlog.ancestors: add support for including revs...
r18081
Robert Stanca
py3: use print_function in test-revlog-ancestry.py
r28764 print('\nAncestors of 7, 5 and 3, including revs')
Siddharth Agarwal
revlog.ancestors: add support for including revs...
r18081 for r in repo.changelog.ancestors([7, 5, 3], inclusive=True):
Robert Stanca
py3: use print_function in test-revlog-ancestry.py
r28764 print(r, end=' ')
Siddharth Agarwal
revlog.ancestors: add support for including revs...
r18081
Stefano Tortarolo
Add ancestors and descendants to revlog...
r6872 # Descendants
Robert Stanca
py3: use print_function in test-revlog-ancestry.py
r28764 print('\n\nDescendants of 5')
Bryan O'Sullivan
revlog: descendants(*revs) becomes descendants(revs) (API)...
r16867 for r in repo.changelog.descendants([5]):
Robert Stanca
py3: use print_function in test-revlog-ancestry.py
r28764 print(r, end=' ')
Stefano Tortarolo
Add ancestors and descendants to revlog...
r6872
Robert Stanca
py3: use print_function in test-revlog-ancestry.py
r28764 print('\nDescendants of 5 and 3')
Bryan O'Sullivan
revlog: descendants(*revs) becomes descendants(revs) (API)...
r16867 for r in repo.changelog.descendants([5, 3]):
Robert Stanca
py3: use print_function in test-revlog-ancestry.py
r28764 print(r, end=' ')
Stefano Tortarolo
Add ancestors and descendants to revlog...
r6872
Robert Stanca
py3: use print_function in test-revlog-ancestry.py
r28764 print('\nDescendants of 5 and 4')
print(*repo.changelog.descendants([5, 4]), sep=' ')