~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to profile_imports.py

  • Committer: John Arbash Meinel
  • Date: 2006-06-18 04:58:38 UTC
  • mto: This revision was merged to the branch mainline in revision 1794.
  • Revision ID: john@arbash-meinel.com-20060618045838-820593e919d762a2
Remove pprint dependency

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
# Copyright (C) 2006 by Canonical Ltd
 
2
# Written by John Arbash Meinel <john@arbash-meinel.com>
2
3
#
3
4
# This program is free software; you can redistribute it and/or modify
4
5
# it under the terms of the GNU General Public License as published by
16
17
 
17
18
"""A custom importer and regex compiler which logs time spent."""
18
19
 
19
 
import os
20
 
import pprint
21
20
import sre
22
21
import sys
23
22
import time
52
51
    """Finish a given entry, and record its cost in time"""
53
52
    global _parent_stack
54
53
 
55
 
    if  _parent_stack[-1] != this:
56
 
        # This should only happen if there is a bug
57
 
        # (used to happen if an import failed)
58
 
        if this not in _parent_stack:
59
 
            import_logfile.write('could not find %s in callstat: %s\n'
60
 
                                % (this, pprint.pformat(_parent_stack)))
61
 
        else:
62
 
            idx = _parent_stack.index(this)
63
 
            import_logfile.write('stripping off extra children: %s\n'
64
 
                                % (_parent_stack[idx:],))
65
 
            _parent_stack = _parent_stack[:idx]
66
 
    else:
67
 
        _parent_stack.pop()
 
54
    assert _parent_stack[-1] == this, \
 
55
        'import stack does not end with this %s: %s' % (this, _parent_stack)
 
56
    _parent_stack.pop()
68
57
    _info[this].append(cost)
69
58
 
70
59