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