def _process_line_stats(line_stats):

    profile_results = []

    if not line_stats:
        return profile_results

    # We want timings in ms (instead of CPython's microseconds)
    multiplier = line_stats.unit / 1e-3

    for key, timings in sorted(line_stats.timings.items()):
        if not timings:
            continue

        filename, start_lineno, func_name = key

        all_lines = linecache.getlines(filename)
        sublines = inspect.getblock(all_lines[start_lineno - 1:])
        end_lineno = start_lineno + len(sublines)

        line_to_timing = collections.defaultdict(lambda: (-1, 0))

        for (lineno, nhits, time) in timings:
            line_to_timing[lineno] = (nhits, time)

        padded_timings = []

        for lineno in range(start_lineno, end_lineno):
            nhits, time = line_to_timing[lineno]
            padded_timings.append((lineno, nhits, time))

        timings = []

        result = {
            'filename': filename,
            'start_lineno': start_lineno,
            'func_name': func_name,
            'total_time_ms': (sum([time for _, _, time in padded_timings]) *
                    multiplier),
            'timings': []
        }

        result['total_time_ms_s'] = '%.0f' % result['total_time_ms']

        for (lineno, nhits, time) in padded_timings:
            time_ms = time * multiplier
            perc_time = (100.0 * time_ms) / result['total_time_ms']

            result['timings'].append({
                'lineno': lineno,
                'line': all_lines[lineno - 1],
                'perc_time': perc_time,
                'perc_time_s': '%.1f' % perc_time,
                'time_ms': time_ms,
                'time_ms_s': "%.2f" % time_ms,
                'numhits': nhits
            })

        profile_results.append(result)

    return profile_results
Convert line_profiler.LineStats instance into a dict.
dataset/ETHPy150Open gae-init/gae-init-debug/main/libx/gae_mini_profiler/linebyline_profiler.py/_process_line_stats