Check for disappeared newborn files in git.tree_status (bug #8516)
[stgit.git] / stg-prof
blobde7bd13bae9eec619ae4baf46e65475602d52979
1 #!/usr/bin/env python
2 # -*- python-mode -*-
3 """Takes care of starting the Init function
4 """
6 __copyright__ = """
7 Copyright (C) 2005, Catalin Marinas <catalin.marinas@gmail.com>
9 This program is free software; you can redistribute it and/or modify
10 it under the terms of the GNU General Public License version 2 as
11 published by the Free Software Foundation.
13 This program is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details.
18 You should have received a copy of the GNU General Public License
19 along with this program; if not, write to the Free Software
20 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21 """
23 import sys, os
24 import profile, pstats, time
26 # Try to detect where it is run from and set prefix and the search path.
27 # It is assumed that the user installed StGIT using the --prefix= option
28 prefix, bin = os.path.split(sys.path[0])
30 if bin == 'bin' and prefix != sys.prefix:
31 sys.prefix = prefix
32 sys.exec_prefix = prefix
34 major, minor = sys.version_info[0:2]
35 local_path = [os.path.join(prefix, 'lib', 'python'),
36 os.path.join(prefix, 'lib', 'python%s.%s' % (major, minor)),
37 os.path.join(prefix, 'lib', 'python%s.%s' % (major, minor),
38 'site-packages')]
39 sys.path = local_path + sys.path
41 from stgit.main import main
43 if __name__ == '__main__':
44 start_time = time.time()
45 def timer():
46 return time.time() - start_time
48 prof = profile.Profile(timer)
49 try:
50 prof.run('main()')
51 except SystemExit:
52 pass
53 pstats.Stats(prof).strip_dirs().sort_stats(-1).print_stats().print_callees()