Exemple #1
0
 def profile_package(self):
     """Returns memory stats for a package."""
     target_modules = base_profiler.get_pkg_module_names(self._run_object)
     try:
         with _CodeEventsTracker(target_modules) as prof:
             prof.compute_mem_overhead()
             runpy.run_path(self._run_object, run_name='__main__')
     except SystemExit:
         pass
     return prof, None
Exemple #2
0
 def testGetPackageCode(self, exists_mock, iter_modules_mock):
     package_path = mock.MagicMock()
     _ = mock.MagicMock()
     modname1, modname2 = 'module1', 'module2'
     fobj1, fobj2 = mock.MagicMock(), mock.MagicMock()
     fobj1.path = '/path/to/module'
     fobj2.path = '/path/to/module'
     iter_modules_mock.return_value = [(fobj1, modname1, _),
                                       (fobj2, modname2, _)]
     exists_mock.return_value = True
     result = base_profiler.get_pkg_module_names(package_path)
     self.assertEqual(
         result,
         {'/path/to/module/module1.py', '/path/to/module/module2.py'})