Exemplo n.º 1
0
    def test_profile_memory_twice_by_samedecorator(self):

        helper.profile_memory(
            self.example_package + 'example_a.example_function_a',
            self.example_package + 'example_memory_profile_decorator', True,
            True)

        helper.profile_memory(
            self.example_package + 'example_a.example_function_a',
            self.example_package + 'example_memory_profile_decorator', False,
            True)

        healthnmon.tests.profiler.MEMORY_PROFILE_CALLED_FUNCTION = []

        self.assertEqual('Example function', example_a.example_function_a())
        exampleA = example_a.ExampleClassA()
        exampleA.example_method()
        ret_a = exampleA.example_method_add(3, 5)
        self.assertEqual(ret_a, 8)

        package_a = self.example_package + 'example_a.'
        self.assertTrue(package_a + 'example_function_a' in healthnmon.tests.
                        profiler.MEMORY_PROFILE_CALLED_FUNCTION)

        self.assertFalse(
            package_a + 'ExampleClassA.example_method' in
            healthnmon.tests.profiler.MEMORY_PROFILE_CALLED_FUNCTION)
        self.assertFalse(
            package_a + 'ExampleClassA.example_method_add' in
            healthnmon.tests.profiler.MEMORY_PROFILE_CALLED_FUNCTION)
Exemplo n.º 2
0
    def test_profile_memory_twice_by_samedecorator(self):

        helper.profile_memory(
            self.example_package + 'example_a.example_function_a',
            self.example_package + 'example_memory_profile_decorator', True, True)

        helper.profile_memory(
            self.example_package + 'example_a.example_function_a',
            self.example_package + 'example_memory_profile_decorator', False, True)

        healthnmon.tests.profiler.MEMORY_PROFILE_CALLED_FUNCTION = []

        self.assertEqual('Example function', example_a.example_function_a())
        exampleA = example_a.ExampleClassA()
        exampleA.example_method()
        ret_a = exampleA.example_method_add(3, 5)
        self.assertEqual(ret_a, 8)

        package_a = self.example_package + 'example_a.'
        self.assertTrue(package_a + 'example_function_a'
                        in healthnmon.tests.profiler.MEMORY_PROFILE_CALLED_FUNCTION)

        self.assertFalse(package_a + 'ExampleClassA.example_method'
                         in healthnmon.tests.profiler.MEMORY_PROFILE_CALLED_FUNCTION)
        self.assertFalse(package_a + 'ExampleClassA.example_method_add'
                         in healthnmon.tests.profiler.MEMORY_PROFILE_CALLED_FUNCTION)
Exemplo n.º 3
0
    def test_disable_profile_cputime_by_decorator(self):
        helper.profile_cputime(self.example_package + 'example_a',
                               self.example_package + 'example_cpu_profile_decorator', False)

        healthnmon.tests.profiler.CPU_PROFILE_CALLED_FUNCTION = []

        self.assertEqual('Example function', example_a.example_function_a())
        exampleA = example_a.ExampleClassA()
        exampleA.example_method()
        ret_a = exampleA.example_method_add(3, 5)
        self.assertEqual(ret_a, 8)

        package_a = self.example_package + 'example_a.'
        self.assertTrue(package_a + 'example_function_a'
                        in healthnmon.tests.profiler.CPU_PROFILE_CALLED_FUNCTION)

        self.assertTrue(package_a + 'ExampleClassA.example_method'
                        in healthnmon.tests.profiler.CPU_PROFILE_CALLED_FUNCTION)
        self.assertTrue(package_a + 'ExampleClassA.example_method_add'
                        in healthnmon.tests.profiler.CPU_PROFILE_CALLED_FUNCTION)
        self.assertEqual(len(profile_cpu.modules), 0)
Exemplo n.º 4
0
    def test_disable_profile_cputime_by_decorator(self):
        helper.profile_cputime(
            self.example_package + 'example_a',
            self.example_package + 'example_cpu_profile_decorator', False)

        healthnmon.tests.profiler.CPU_PROFILE_CALLED_FUNCTION = []

        self.assertEqual('Example function', example_a.example_function_a())
        exampleA = example_a.ExampleClassA()
        exampleA.example_method()
        ret_a = exampleA.example_method_add(3, 5)
        self.assertEqual(ret_a, 8)

        package_a = self.example_package + 'example_a.'
        self.assertTrue(package_a + 'example_function_a' in
                        healthnmon.tests.profiler.CPU_PROFILE_CALLED_FUNCTION)

        self.assertTrue(package_a + 'ExampleClassA.example_method' in
                        healthnmon.tests.profiler.CPU_PROFILE_CALLED_FUNCTION)
        self.assertTrue(package_a + 'ExampleClassA.example_method_add' in
                        healthnmon.tests.profiler.CPU_PROFILE_CALLED_FUNCTION)
        self.assertEqual(len(profile_cpu.modules), 0)