def results(self):
        total_samples = len(self.samples)

        # Compress the results by keeping an array of all of the frame
        # descriptions (we expect that there won't be that many total of them).
        # Each actual stack trace is given as an ordered list of indexes into
        # the array of frames.
        frames = []
        frame_indexes = {}

        for sample in self.samples:
            for frame_desc in sample.get_frame_descriptions():
                if not frame_desc in frame_indexes:
                    frame_indexes[frame_desc] = len(frames)
                    frames.append(frame_desc)

        samples = [{
                "timestamp_ms": util.milliseconds_fmt(sample.timestamp_ms, 1),
                "memory_used": self.memory_samples.get(sample.timestamp_ms),
                "stack_frames": [frame_indexes[desc]
                                 for desc in sample.get_frame_descriptions()]
            } for sample in self.samples]

        # For convenience, we also send along with each sample the index
        # of the previous and next memory samples.
        if self.memory_sample_every:
            Profile.annotate_prev_samples(samples, 'prev_memory_sample_index')
            Profile.annotate_prev_samples(samples, 'next_memory_sample_index',
                                          rev=True)

        results = {
                "frame_names": [
                    util.short_method_fmt(frame) for frame in frames],
                "samples": samples,
                "total_samples": total_samples,
            }

        if self.memory_sample_every and self.memory_samples:
            results.update({
                "start_memory": round(self.memory_samples.values()[0], 2),
                "max_memory": round(max(self.memory_samples.values()), 2),
                "end_memory": round(self.memory_samples.values()[-1], 2),
            })

        return results
Return sampling results in a dictionary for template context.
dataset/ETHPy150Open gae-init/gae-init-debug/main/libx/gae_mini_profiler/sampling_profiler.py/Profile.results