def test_pstats_data(self):
        stats = pstats.Stats(self.profile)
        converter = CalltreeConverter(stats)
        out_file = StringIO()

        converter.output(out_file)
        self.assertEqual(out_file.getvalue(), expected_output)
    def test_direct_entries(self):
        entries = self.profile.getstats()
        converter = CalltreeConverter(entries)
        out_file = StringIO()

        converter.output(out_file)
        self.assertEqual(out_file.getvalue(), expected_output)
Ejemplo n.º 3
0
    def test_direct_entries(self):
        entries = self.profile.getstats()
        converter = CalltreeConverter(entries)
        out_file = StringIO()

        converter.output(out_file)
        self.assertEqual(out_file.getvalue(), expected_output)
Ejemplo n.º 4
0
    def test_pstats_data(self):
        stats = pstats.Stats(self.profile)
        converter = CalltreeConverter(stats)
        out_file = StringIO()

        converter.output(out_file)
        self.assertEqual(out_file.getvalue(), expected_output)
Ejemplo n.º 5
0
    def process(self, profiler, start, end, environment, suggestive_file_name):
        """
        Process the results
        :param profiler:                The profiler
        :type  profiler:                cProfile.Profile
        :param start:                   Start of profiling
        :type start:                    int
        :param end:                     End of profiling
        :type end:                      int
        :param environment:             The environment
        :type  environment:             Environment
        :param suggestive_file_name:    A suggestive file name
        :type  suggestive_file_name:    str
        """

        filename = self._prefix + suggestive_file_name + self._suffix
        filepath = os.path.join(self._profile_path, filename)

        converter = CalltreeConverter(profiler.getstats())
        f = self._app.fs().write_stream(filepath)

        try:
            converter.output(f)
        finally:
            f.close()