sapling/scripts/traceprof.py
Jun Wu 3ed8d7b512 smartlog: add a simple ancestor cache
Summary:
`revlog.ancestor` is expensive on long changelog, but is only called a few
(about 30) times for smartlog usage. Therefore we could simply cache the
result in a key-value database.

This speeds up smartlog by about 200ms.

Test Plan: Added a new test

Reviewers: #mercurial, stash

Reviewed By: stash

Subscribers: stash, mjpieters

Differential Revision: https://phabricator.intern.facebook.com/D5135746

Signature: t1:5135746:1495783503:411260551fd29fda42c9fc809b56f8f77fb2eaf4
2017-05-26 09:03:58 -07:00

21 lines
540 B
Python
Executable File

#!/usr/bin/env python
from __future__ import absolute_import, print_function
from hgext3rd import traceprof
from mercurial import ui
import os
import sys
if __name__ == '__main__':
sys.argv = sys.argv[1:]
if not sys.argv:
print("usage: traceprof.py <script> <arguments...>", file=sys.stderr)
sys.exit(2)
sys.path.insert(0, os.path.abspath(os.path.dirname(sys.argv[0])))
u = ui.ui()
u.setconfig('traceprof', 'timethreshold', 0)
with traceprof.profile(u, sys.stderr):
execfile(sys.argv[0])