File: stg-prof

package info (click to toggle)
stgit 0.19-1
  • links: PTS, VCS
  • area: main
  • in suites: bullseye, sid
  • size: 1,752 kB
  • sloc: python: 10,558; sh: 5,739; lisp: 2,678; makefile: 142; perl: 42
file content (59 lines) | stat: -rwxr-xr-x 1,933 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# -*- python-mode -*-
"""Run stg with profiling enabled."""
from __future__ import (absolute_import, division, print_function,
                        unicode_literals)
import os
import profile
import pstats
import sys
import time

__copyright__ = """
Copyright (C) 2005, Catalin Marinas <catalin.marinas@gmail.com>

This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License version 2 as
published by the Free Software Foundation.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program; if not, see http://www.gnu.org/licenses/.
"""

if __name__ == '__main__':
    # Try to detect where it is run from and set prefix and the search path.
    # It is assumed that the user installed StGIT using the --prefix= option
    prefix, bin = os.path.split(sys.path[0])

    if bin == 'bin' and prefix != sys.prefix:
        sys.prefix = prefix
        sys.exec_prefix = prefix

        major, minor = sys.version_info[0:2]
        local_path = [
            os.path.join(prefix, 'lib', 'python'),
            os.path.join(prefix, 'lib', 'python%s.%s' % (major, minor)),
            os.path.join(prefix, 'lib', 'python%s.%s' % (major, minor),
                         'site-packages')]
        sys.path = local_path + sys.path

    from stgit.main import main  # noqa

    start_time = time.time()

    def timer():
        return time.time() - start_time

    prof = profile.Profile(timer)
    try:
        prof.run('main()')
    except SystemExit:
        pass
    stats = pstats.Stats(prof)
    stats.strip_dirs().sort_stats(-1).print_stats().print_callees()