How to use the pprofile.LineIterator function in pprofile

To help you get started, we’ve selected a few pprofile examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github vpelletier / pprofile / pprofile.py View on Github external
return
        def percent(value, scale):
            if scale == 0:
                return 0
            return value * 100 / scale
        for name in self._getFileNameList(filename):
            file_timing = file_dict[name]
            file_total_time = file_timing.getTotalTime()
            call_list_by_line = file_timing.getCallListByLine()
            print(u'File: %s' % name, file=out)
            print(u'File duration: %gs (%.2f%%)' % (file_total_time,
                percent(file_total_time, total_time)), file=out)
            print(_ANNOTATE_HEADER, file=out)
            print(_ANNOTATE_HORIZONTAL_LINE, file=out)
            last_line = file_timing.getLastLine()
            for lineno, line in LineIterator(
                self._getline,
                file_timing.filename,
                file_timing.global_dict,
            ):
                if not line and lineno > last_line:
                    break
                hits, duration = file_timing.getHitStatsFor(lineno)
                print(_ANNOTATE_FORMAT % {
                    u'lineno': lineno,
                    u'hits': hits,
                    u'time': duration,
                    u'time_per_hit': duration / hits if hits else 0,
                    u'percent': percent(duration, total_time),
                    u'line': (line or u'').rstrip(),
                }, file=out)
                for (
github vpelletier / pprofile / pprofile.py View on Github external
def next(self):
            lineno, line = super(LineIterator, self).next()
            if self._encoding:
                line = line.decode(self._encoding, errors='replace')
            return lineno, line
else: