2 # -*- coding: utf-8 -*-
4 """Run stg with profiling enabled."""
5 from __future__
import (absolute_import
, division
, print_function
,
14 Copyright (C) 2005, Catalin Marinas <catalin.marinas@gmail.com>
16 This program is free software; you can redistribute it and/or modify
17 it under the terms of the GNU General Public License version 2 as
18 published by the Free Software Foundation.
20 This program is distributed in the hope that it will be useful,
21 but WITHOUT ANY WARRANTY; without even the implied warranty of
22 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
23 GNU General Public License for more details.
25 You should have received a copy of the GNU General Public License
26 along with this program; if not, see http://www.gnu.org/licenses/.
29 if __name__
== '__main__':
30 # Try to detect where it is run from and set prefix and the search path.
31 # It is assumed that the user installed StGIT using the --prefix= option
32 prefix
, bin
= os
.path
.split(sys
.path
[0])
34 if bin
== 'bin' and prefix
!= sys
.prefix
:
36 sys
.exec_prefix
= prefix
38 major
, minor
= sys
.version_info
[0:2]
40 os
.path
.join(prefix
, 'lib', 'python'),
41 os
.path
.join(prefix
, 'lib', 'python%s.%s' % (major
, minor
)),
42 os
.path
.join(prefix
, 'lib', 'python%s.%s' % (major
, minor
),
44 sys
.path
= local_path
+ sys
.path
46 from stgit
.main
import main
# noqa
48 start_time
= time
.time()
51 return time
.time() - start_time
53 prof
= profile
.Profile(timer
)
58 stats
= pstats
.Stats(prof
)
59 stats
.strip_dirs().sort_stats(-1).print_stats().print_callees()