~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/lsprof.py

  • Committer: Jelmer Vernooij
  • Date: 2010-12-20 11:57:14 UTC
  • mto: This revision was merged to the branch mainline in revision 5577.
  • Revision ID: jelmer@samba.org-20101220115714-2ru3hfappjweeg7q
Don't use no-plugins.

Show diffs side-by-side

added added

removed removed

Lines of Context:
112
112
 
113
113
 
114
114
class Stats(object):
115
 
    """XXX docstring"""
 
115
    """Wrapper around the collected data.
 
116
 
 
117
    A Stats instance is created when the profiler finishes. Normal
 
118
    usage is to use save() to write out the data to a file, or pprint()
 
119
    to write human-readable information to the command line.
 
120
    """
116
121
 
117
122
    def __init__(self, data, threads):
118
123
        self.data = data
119
124
        self.threads = threads
120
125
 
121
126
    def sort(self, crit="inlinetime"):
122
 
        """XXX docstring"""
 
127
        """Sort the data by the supplied critera.
 
128
 
 
129
        :param crit: the data attribute used as the sort key."""
123
130
        if crit not in profiler_entry.__dict__:
124
131
            raise ValueError, "Can't sort by %s" % crit
125
132
        self.data.sort(lambda b, a: cmp(getattr(a, crit),
130
137
                                              getattr(b, crit)))
131
138
 
132
139
    def pprint(self, top=None, file=None):
133
 
        """XXX docstring"""
 
140
        """Pretty-print the data as plain text for human consumption.
 
141
 
 
142
        :param top: only output the top n entries.
 
143
            The default value of None means output all data.
 
144
        :param file: the output file; if None, output will
 
145
            default to stdout."""
134
146
        if file is None:
135
147
            file = sys.stdout
136
148
        d = self.data