Esempio n. 1
0
 def setUp(self):
     if xprofile is None:
         raise SkipTest
     self.profilers = [
         xprofile.get_profiler('cProfile'),
         xprofile.get_profiler('eventlet.green.profile')
     ]
Esempio n. 2
0
 def setUp(self):
     self.profile_file = tempfile.mktemp('profile', 'unittest')
     self.profilers = [xprofile.get_profiler('cProfile'),
                       xprofile.get_profiler('eventlet.green.profile')]
     for p in self.profilers:
         p.runctx('import os;os.getcwd();', globals(), locals())
         p.dump_stats(self.profile_file)
         self.stats2 = Stats2(self.profile_file)
         self.selections = [['getcwd'], ['getcwd', -1],
                            ['getcwd', -10], ['getcwd', 0.1]]
Esempio n. 3
0
 def setUp(self):
     self.profile_file = tempfile.mktemp('profile', 'unittest')
     self.profilers = [xprofile.get_profiler('cProfile'),
                       xprofile.get_profiler('eventlet.green.profile')]
     for p in self.profilers:
         p.runctx('import os;os.getcwd();', globals(), locals())
         p.dump_stats(self.profile_file)
         self.stats2 = Stats2(self.profile_file)
         self.selections = [['getcwd'], ['getcwd', -1],
                            ['getcwd', -10], ['getcwd', 0.1]]
Esempio n. 4
0
    def setUp(self):
        self.log_filename_prefix1 = tempfile.mkdtemp() + '/unittest.profile'
        self.profile_log1 = ProfileLog(self.log_filename_prefix1, False)
        self.pids1 = ['123', '456', str(os.getpid())]
        profiler1 = xprofile.get_profiler('eventlet.green.profile')
        for pid in self.pids1:
            profiler1.runctx('import os;os.getcwd();', globals(), locals())
            self.profile_log1.dump_profile(profiler1, pid)

        self.log_filename_prefix2 = tempfile.mkdtemp() + '/unittest.profile'
        self.profile_log2 = ProfileLog(self.log_filename_prefix2, True)
        self.pids2 = ['321', '654', str(os.getpid())]
        profiler2 = xprofile.get_profiler('eventlet.green.profile')
        for pid in self.pids2:
            profiler2.runctx('import os;os.getcwd();', globals(), locals())
            self.profile_log2.dump_profile(profiler2, pid)
Esempio n. 5
0
 def setUp(self):
     if xprofile is None:
         raise SkipTest
     self.app = ProfileMiddleware(FakeApp, {})
     self.log_files = []
     self.tempdir = tempfile.mkdtemp()
     self.log_filename_prefix = self.tempdir + '/unittest.profile'
     self.profile_log = ProfileLog(self.log_filename_prefix, False)
     self.pids = ['123', '456', str(os.getpid())]
     profiler = xprofile.get_profiler('eventlet.green.profile')
     for pid in self.pids:
         profiler.runctx('import os;os.getcwd();', globals(), locals())
         self.log_files.append(self.profile_log.dump_profile(profiler, pid))
     self.viewer = HTMLViewer('__profile__', 'eventlet.green.profile',
                              self.profile_log)
     body = "profile=123&profile=456&sort=time&sort=nc&limit=10"\
         + "&fulldirs=1&nfl_filter=getcwd&query=query&metric=nc"
     wsgi_input = StringIO.StringIO(body)
     environ = {
         'REQUEST_METHOD': 'GET',
         'QUERY_STRING': 'profile=all',
         'wsgi.input': wsgi_input
     }
     req = Request.blank('/__profile__/', environ=environ)
     self.query_dict = self.app._combine_body_qs(req)
Esempio n. 6
0
    def setUp(self):
        self.dir1 = tempfile.mkdtemp()
        self.log_filename_prefix1 = self.dir1 + '/unittest.profile'
        self.profile_log1 = ProfileLog(self.log_filename_prefix1, False)
        self.pids1 = ['123', '456', str(os.getpid())]
        profiler1 = xprofile.get_profiler('eventlet.green.profile')
        for pid in self.pids1:
            profiler1.runctx('import os;os.getcwd();', globals(), locals())
            self.profile_log1.dump_profile(profiler1, pid)

        self.dir2 = tempfile.mkdtemp()
        self.log_filename_prefix2 = self.dir2 + '/unittest.profile'
        self.profile_log2 = ProfileLog(self.log_filename_prefix2, True)
        self.pids2 = ['321', '654', str(os.getpid())]
        profiler2 = xprofile.get_profiler('eventlet.green.profile')
        for pid in self.pids2:
            profiler2.runctx('import os;os.getcwd();', globals(), locals())
            self.profile_log2.dump_profile(profiler2, pid)
Esempio n. 7
0
 def test_dump_profile(self):
     prof = xprofile.get_profiler('eventlet.green.profile')
     prof.runctx('import os;os.getcwd();', globals(), locals())
     prof.create_stats()
     pfn = self.profile_log1.dump_profile(prof, os.getpid())
     self.assertTrue(os.path.exists(pfn))
     os.remove(pfn)
     pfn = self.profile_log2.dump_profile(prof, os.getpid())
     self.assertTrue(os.path.exists(pfn))
     os.remove(pfn)
Esempio n. 8
0
 def test_dump_profile(self):
     prof = xprofile.get_profiler('eventlet.green.profile')
     prof.runctx('import os;os.getcwd();', globals(), locals())
     prof.create_stats()
     pfn = self.profile_log1.dump_profile(prof, os.getpid())
     self.assertTrue(os.path.exists(pfn))
     os.remove(pfn)
     pfn = self.profile_log2.dump_profile(prof, os.getpid())
     self.assertTrue(os.path.exists(pfn))
     os.remove(pfn)
Esempio n. 9
0
 def setUp(self):
     self.got_statuses = []
     self.app = ProfileMiddleware(FakeApp, {})
     self.tempdir = os.path.dirname(self.app.log_filename_prefix)
     self.pids = ['123', '456', str(os.getpid())]
     profiler = xprofile.get_profiler('eventlet.green.profile')
     for pid in self.pids:
         path = self.app.log_filename_prefix + pid
         profiler.runctx('import os;os.getcwd();', globals(), locals())
         profiler.dump_stats(path)
         profiler.runctx('import os;os.getcwd();', globals(), locals())
         profiler.dump_stats(path + '.tmp')
Esempio n. 10
0
 def setUp(self):
     self.got_statuses = []
     self.app = ProfileMiddleware(FakeApp, {})
     self.tempdir = os.path.dirname(self.app.log_filename_prefix)
     self.pids = ['123', '456', str(os.getpid())]
     profiler = xprofile.get_profiler('eventlet.green.profile')
     for pid in self.pids:
         path = self.app.log_filename_prefix + pid
         profiler.runctx('import os;os.getcwd();', globals(), locals())
         profiler.dump_stats(path)
         profiler.runctx('import os;os.getcwd();', globals(), locals())
         profiler.dump_stats(path + '.tmp')
Esempio n. 11
0
 def setUp(self):
     self.app = ProfileMiddleware(FakeApp, {})
     self.log_files = []
     self.tempdir = tempfile.mkdtemp()
     self.log_filename_prefix = self.tempdir + '/unittest.profile'
     self.profile_log = ProfileLog(self.log_filename_prefix, False)
     self.pids = ['123', '456', str(os.getpid())]
     profiler = xprofile.get_profiler('eventlet.green.profile')
     for pid in self.pids:
         profiler.runctx('import os;os.getcwd();', globals(), locals())
         self.log_files.append(self.profile_log.dump_profile(profiler, pid))
     self.viewer = HTMLViewer('__profile__', 'eventlet.green.profile',
                              self.profile_log)
     body = (b"profile=123&profile=456&sort=time&sort=nc&limit=10"
             b"&fulldirs=1&nfl_filter=getcwd&query=query&metric=nc")
     wsgi_input = BytesIO(body)
     environ = {'REQUEST_METHOD': 'GET',
                'QUERY_STRING': 'profile=all',
                'wsgi.input': wsgi_input}
     req = Request.blank('/__profile__/', environ=environ)
     self.query_dict = self.app._combine_body_qs(req)
Esempio n. 12
0
 def setUp(self):
     self.profilers = [xprofile.get_profiler('cProfile'),
                       xprofile.get_profiler('eventlet.green.profile')]
Esempio n. 13
0
 def test_get_profiler(self):
     self.assertTrue(xprofile.get_profiler('cProfile') is not None)
     self.assertTrue(xprofile.get_profiler('eventlet.green.profile')
                     is not None)
Esempio n. 14
0
 def setUp(self):
     self.profilers = [
         xprofile.get_profiler('cProfile'),
         xprofile.get_profiler('eventlet.green.profile')
     ]
Esempio n. 15
0
 def test_get_profiler(self):
     self.assertTrue(xprofile.get_profiler('cProfile') is not None)
     self.assertTrue(
         xprofile.get_profiler('eventlet.green.profile') is not None)
Esempio n. 16
0
 def test_get_profiler(self):
     if xprofile is None:
         raise SkipTest
     self.assertTrue(xprofile.get_profiler('cProfile') is not None)
     self.assertTrue(xprofile.get_profiler('eventlet.green.profile')
                     is not None)
Esempio n. 17
0
 def setUp(self):
     if xprofile is None:
         raise SkipTest
     self.profilers = [xprofile.get_profiler('cProfile'),
                       xprofile.get_profiler('eventlet.green.profile')]
Esempio n. 18
0
 def test_get_profiler(self):
     if xprofile is None:
         raise SkipTest
     self.assertTrue(xprofile.get_profiler('cProfile') is not None)
     self.assertTrue(xprofile.get_profiler('eventlet.green.profile')
                     is not None)