Exemple #1
0
 def testRequest(self):
     response = urllib.request.urlopen("http://%s:%s/profile" % (_HOST, _PORT))
     response_data = stats_server.decompress_data(response.read())
     stats = json.loads(response_data.decode("utf-8"))
     self.assertEqual(len(stats), 1)
     self.assertEqual(stats[0]["objectName"], _MODULE_FILENAME)
     self.assertDictEqual(stats[0]["heatmap"], {"1": 1})
     self.assertListEqual(stats[0]["srcCode"], _DUMMY_MODULE_SOURCELINES)
 def testRequest(self):
     profiler.run(self._func, 'c', ('foo', 'bar'), host=_HOST, port=_PORT)
     response = urllib.request.urlopen('http://%s:%s/profile' %
                                       (_HOST, _PORT))
     response_data = stats_server.decompress_data(response.read())
     stats = json.loads(response_data.decode('utf-8'))
     self.assertEqual(stats['c']['objectName'], '_func (function)')
     self.assertEqual(stats['c']['totalCalls'], 2)
Exemple #3
0
 def testRequest(self):
     response = urllib.request.urlopen('http://%s:%s/profile' %
                                       (_HOST, _PORT))
     response_data = stats_server.decompress_data(response.read())
     stats = json.loads(response_data.decode('utf-8'))
     self.assertEqual(stats['objectName'], '%s (package)' % _PACKAGE_PATH)
     self.assertTrue(stats['totalEvents'] > 0)
     self.assertTrue(len(stats['objectsCount']) > 0)
Exemple #4
0
 def testRequest(self):
     response = urllib.request.urlopen("http://%s:%s/profile" % (_HOST, _PORT))
     response_data = stats_server.decompress_data(response.read())
     stats = json.loads(response_data.decode("utf-8"))
     self.assertEqual(stats["objectName"], "%s (package)" % _PACKAGE_PATH)
     self.assertTrue("sampleInterval" in stats)
     self.assertTrue("runTime" in stats)
     self.assertTrue("totalSamples" in stats)
Exemple #5
0
 def testRequest(self):
     runner.run(
         self._func, 'm', ('foo', 'bar'), host=_HOST, port=_PORT)
     response = urllib.request.urlopen(
         'http://%s:%s/profile' % (_HOST, _PORT))
     response_data = stats_server.decompress_data(response.read())
     stats = json.loads(response_data.decode('utf-8'))
     self.assertEqual(stats['m']['objectName'], '_func (function)')
     self.assertEqual(stats['m']['totalEvents'], 2)
Exemple #6
0
 def testRequest(self):
     response = urllib.request.urlopen('http://%s:%s/profile' %
                                       (_HOST, _PORT))
     response_data = stats_server.decompress_data(response.read())
     stats = json.loads(response_data.decode('utf-8'))
     self.assertEqual(len(stats), 1)
     self.assertEqual(stats[0]['objectName'], _MODULE_FILENAME)
     self.assertDictEqual(stats[0]['heatmap'], {'1': 1})
     self.assertListEqual(stats[0]['srcCode'], _DUMMY_MODULE_SOURCELINES)
Exemple #7
0
 def testRequest(self):
     runner.run(self._func, "c", ("foo", "bar"), host=_HOST, port=_PORT)
     response = urllib.request.urlopen("http://%s:%s/profile" % (_HOST, _PORT))
     response_data = stats_server.decompress_data(response.read())
     stats = json.loads(response_data.decode("utf-8"))
     self.assertEqual(stats["c"]["objectName"], "_func (function)")
     self.assertTrue("sampleInterval" in stats["c"])
     self.assertTrue("runTime" in stats["c"])
     self.assertTrue("totalSamples" in stats["c"])
 def testRequest(self):
     response = urllib.request.urlopen('http://%s:%s/profile' %
                                       (_HOST, _PORT))
     response_data = stats_server.decompress_data(response.read())
     stats = json.loads(response_data.decode('utf-8'))
     self.assertEqual(stats['objectName'], '%s (package)' % _PACKAGE_NAME)
     self.assertTrue('primitiveCalls' in stats)
     self.assertTrue('runTime' in stats)
     self.assertTrue('totalCalls' in stats)
Exemple #9
0
 def testRequest(self):
     response = urllib.request.urlopen("http://%s:%s/profile" % (_HOST, _PORT))
     response_data = stats_server.decompress_data(response.read())
     stats = json.loads(response_data.decode("utf-8"))
     self.assertEqual(len(stats), 2)
     self.assertTrue("vprof/tests/test_pkg/__main__.py" in stats[0]["objectName"])
     self.assertTrue("vprof/tests/test_pkg/dummy_module.py" in stats[1]["objectName"])
     self.assertListEqual(stats[0]["srcCode"], _MAIN_MODULE_SOURCELINES)
     self.assertListEqual(stats[1]["srcCode"], _DUMMY_MODULE_SOURCELINES)
Exemple #10
0
 def testRequest(self):
     response = urllib.request.urlopen(
         'http://%s:%s/profile' % (_HOST, _PORT))
     response_data = stats_server.decompress_data(response.read())
     stats = json.loads(response_data.decode('utf-8'))
     self.assertEqual(len(stats), 1)
     self.assertEqual(stats[0]['objectName'], _MODULE_FILENAME)
     self.assertDictEqual(stats[0]['heatmap'], {'1': 1})
     self.assertListEqual(stats[0]['srcCode'], _DUMMY_MODULE_SOURCELINES)
Exemple #11
0
 def testRequest(self):
     response = urllib.request.urlopen(
         'http://%s:%s/profile' % (_HOST, _PORT))
     response_data = stats_server.decompress_data(response.read())
     stats = json.loads(response_data.decode('utf-8'))
     self.assertEqual(stats['objectName'], '%s (package)' % _PACKAGE_PATH)
     first_event = stats['codeEvents'][0]
     self.assertEqual(first_event[0], 1)
     self.assertEqual(first_event[1], 1)
     self.assertEqual(first_event[3], '<module>')
Exemple #12
0
 def testRequest(self):
     response = urllib.request.urlopen(
         'http://%s:%s/profile' % (_HOST, _PORT))
     response_data = stats_server.decompress_data(response.read())
     stats = json.loads(response_data.decode('utf-8'))
     self.assertEqual(stats['objectName'], '%s (package)' % _PACKAGE_PATH)
     self.assertTrue('callStats' in stats)
     self.assertTrue('totalTime' in stats)
     self.assertTrue('primitiveCalls' in stats)
     self.assertTrue('totalCalls' in stats)
Exemple #13
0
 def testRequest(self):
     response = urllib.request.urlopen(
         'http://%s:%s/profile' % (_HOST, _PORT))
     response_data = stats_server.decompress_data(response.read())
     stats = json.loads(response_data.decode('utf-8'))
     self.assertEqual(stats['objectName'], '%s (module)' % _MODULE_FILENAME)
     self.assertTrue(len(stats['callStats']) > 0)
     self.assertTrue(stats['totalTime'] > 0)
     self.assertTrue(stats['primitiveCalls'] > 0)
     self.assertTrue(stats['totalCalls'] > 0)
 def testRequest(self):
     response = urllib.request.urlopen('http://%s:%s/profile' %
                                       (_HOST, _PORT))
     response_data = stats_server.decompress_data(response.read())
     stats = json.loads(response_data.decode('utf-8'))
     self.assertEqual(stats['objectName'], '%s (package)' % _PACKAGE_PATH)
     self.assertEqual(stats['sampleInterval'], flame_graph._SAMPLE_INTERVAL)
     self.assertTrue('runTime' in stats)
     self.assertTrue('callStats' in stats)
     self.assertTrue('totalSamples' in stats)
Exemple #15
0
 def testRequest(self):
     response = urllib.request.urlopen(
         'http://%s:%s/profile' % (_HOST, _PORT))
     response_data = stats_server.decompress_data(response.read())
     stats = json.loads(response_data.decode('utf-8'))
     self.assertEqual(stats['objectName'], '%s (package)' % _PACKAGE_PATH)
     self.assertEqual(stats['sampleInterval'], flame_graph._SAMPLE_INTERVAL)
     self.assertTrue('runTime' in stats)
     self.assertTrue('callStats' in stats)
     self.assertTrue('totalSamples' in stats)
Exemple #16
0
 def testRequest(self):
     response = urllib.request.urlopen(
         'http://%s:%s/profile' % (_HOST, _PORT))
     response_data = stats_server.decompress_data(response.read())
     stats = json.loads(response_data.decode('utf-8'))
     self.assertEqual(stats['objectName'], '%s (package)' % _PACKAGE_PATH)
     first_event = stats['codeEvents'][0]
     self.assertEqual(first_event[0], 1)
     self.assertEqual(first_event[1], 1)
     self.assertEqual(first_event[3], '<module>')
 def testRequest(self):
     response = urllib.request.urlopen('http://%s:%s/profile' %
                                       (_HOST, _PORT))
     response_data = stats_server.decompress_data(response.read())
     stats = json.loads(response_data.decode('utf-8'))
     self.assertEqual(stats['objectName'], '%s (module)' % _MODULE_FILENAME)
     self.assertEqual(stats['totalEvents'], 1)
     self.assertEqual(len(stats['codeEvents']), 1)
     self.assertListEqual(
         stats['codeEvents'][0],
         [1, 1, 0.0, '<module>', 'vprof/tests/test_pkg/dummy_module.py'])
Exemple #18
0
 def testRequest(self):
     response = urllib.request.urlopen('http://%s:%s/profile' %
                                       (_HOST, _PORT))
     response_data = stats_server.decompress_data(response.read())
     stats = json.loads(response_data.decode('utf-8'))
     self.assertEqual(len(stats), 2)
     self.assertTrue(
         'vprof/tests/test_pkg/__main__.py' in stats[0]['objectName'])
     self.assertTrue(
         'vprof/tests/test_pkg/dummy_module.py' in stats[1]['objectName'])
     self.assertListEqual(stats[0]['srcCode'], _MAIN_MODULE_SOURCELINES)
     self.assertListEqual(stats[1]['srcCode'], _DUMMY_MODULE_SOURCELINES)
 def testRequest(self):
     runner.run(self._func, 'c', ('foo', 'bar'), host=_HOST, port=_PORT)
     response = urllib.request.urlopen('http://%s:%s/profile' %
                                       (_HOST, _PORT))
     response_data = stats_server.decompress_data(response.read())
     stats = json.loads(response_data.decode('utf-8'))
     self.assertEqual(stats['c']['objectName'], '_func (function)')
     self.assertEqual(stats['c']['sampleInterval'],
                      flame_graph._SAMPLE_INTERVAL)
     self.assertTrue('runTime' in stats['c'])
     self.assertTrue('callStats' in stats['c'])
     self.assertTrue('totalSamples' in stats['c'])
Exemple #20
0
 def testRequest(self):
     runner.run(
         self._func, 'c', ('foo', 'bar'), host=_HOST, port=_PORT)
     response = urllib.request.urlopen(
         'http://%s:%s/profile' % (_HOST, _PORT))
     response_data = stats_server.decompress_data(response.read())
     stats = json.loads(response_data.decode('utf-8'))
     self.assertEqual(stats['c']['objectName'], '_func (function)')
     self.assertEqual(
         stats['c']['sampleInterval'], flame_graph._SAMPLE_INTERVAL)
     self.assertTrue('runTime' in stats['c'])
     self.assertTrue('callStats' in stats['c'])
     self.assertTrue('totalSamples' in stats['c'])
Exemple #21
0
 def testRequest(self):
     profiler.run(self._func, 'h', ('foo', 'bar'), host=_HOST, port=_PORT)
     response = urllib.request.urlopen('http://%s:%s/profile' %
                                       (_HOST, _PORT))
     response_data = stats_server.decompress_data(response.read())
     stats = json.loads(response_data.decode('utf-8'))
     self.assertEqual(len(stats), 1)
     self.assertTrue('function _func' in stats['h'][0]['objectName'])
     self.assertDictEqual(stats['h'][0]['heatmap'], {'91': 1, '92': 1})
     self.assertListEqual(stats['h'][0]['srcCode'],
                          [['line', 90, '        def _func(foo, bar):\n'],
                           ['line', 91, u'            baz = foo + bar\n'],
                           ['line', 92, u'            return baz\n']])
Exemple #22
0
 def testRequest(self):
     runner.run(
         self._func, 'p', ('foo', 'bar'), host=_HOST, port=_PORT)
     response = urllib.request.urlopen(
         'http://%s:%s/profile' % (_HOST, _PORT))
     response_data = stats_server.decompress_data(response.read())
     stats = json.loads(response_data.decode('utf-8'))
     curr_filename = inspect.getabsfile(inspect.currentframe())
     self.assertEqual(stats['p']['objectName'],
                      '_func @ %s (function)' % curr_filename)
     self.assertTrue(len(stats['p']['callStats']) > 0)
     self.assertTrue(stats['p']['totalTime'] > 0)
     self.assertTrue(stats['p']['primitiveCalls'] > 0)
     self.assertTrue(stats['p']['totalCalls'] > 0)
Exemple #23
0
 def testRequest(self):
     response = urllib.request.urlopen('http://%s:%s/profile' %
                                       (_HOST, _PORT))
     response_data = stats_server.decompress_data(response.read())
     stats = json.loads(response_data.decode('utf-8'))
     self.assertEqual(stats['objectName'], _PACKAGE_PATH)
     self.assertTrue(stats['runTime'] > 0)
     heatmap_files = {heatmap['name'] for heatmap in stats['heatmaps']}
     self.assertTrue(
         os.path.abspath('vprof/tests/test_pkg/__main__.py') in
         heatmap_files)
     self.assertTrue(
         os.path.abspath('vprof/tests/test_pkg/dummy_module.py') in
         heatmap_files)
Exemple #24
0
 def testRequest(self):
     response = urllib.request.urlopen(
         'http://%s:%s/profile' % (_HOST, _PORT))
     response_data = stats_server.decompress_data(response.read())
     stats = json.loads(response_data.decode('utf-8'))
     self.assertEqual(stats['objectName'], _PACKAGE_PATH)
     heatmaps = stats['heatmaps']
     self.assertEqual(len(heatmaps), 2)
     self.assertTrue(
         'vprof/tests/test_pkg/__main__.py' in heatmaps[0]['name'])
     self.assertTrue(
         'vprof/tests/test_pkg/dummy_module.py' in heatmaps[1]['name'])
     self.assertListEqual(heatmaps[0]['srcCode'], _MAIN_MODULE_SOURCELINES)
     self.assertListEqual(heatmaps[1]['srcCode'], _DUMMY_MODULE_SOURCELINES)
Exemple #25
0
 def testRequest(self):
     runner.run(
         self._func, 'h', ('foo', 'bar'), host=_HOST, port=_PORT)
     response = urllib.request.urlopen(
         'http://%s:%s/profile' % (_HOST, _PORT))
     response_data = stats_server.decompress_data(response.read())
     stats = json.loads(response_data.decode('utf-8'))
     self.assertEqual(len(stats), 1)
     self.assertTrue('function _func' in stats['h'][0]['objectName'])
     self.assertDictEqual(
         stats['h'][0]['heatmap'], {'91': 1, '92': 1})
     self.assertListEqual(
         stats['h'][0]['srcCode'],
         [['line', 90, '        def _func(foo, bar):\n'],
          ['line', 91, u'            baz = foo + bar\n'],
          ['line', 92, u'            return baz\n']])
Exemple #26
0
 def testRequest(self):
     runner.run(self._func, 'm', ('foo', 'bar'), host=_HOST, port=_PORT)
     response = urllib.request.urlopen('http://%s:%s/profile' %
                                       (_HOST, _PORT))
     response_data = stats_server.decompress_data(response.read())
     stats = json.loads(response_data.decode('utf-8'))
     curr_filename = inspect.getabsfile(inspect.currentframe())
     self.assertEqual(stats['m']['objectName'],
                      '_func @ %s (function)' % curr_filename)
     self.assertEqual(stats['m']['totalEvents'], 2)
     self.assertEqual(stats['m']['codeEvents'][0][0], 1)
     self.assertEqual(stats['m']['codeEvents'][0][1], 91)
     self.assertEqual(stats['m']['codeEvents'][0][3], '_func')
     self.assertEqual(stats['m']['codeEvents'][1][0], 2)
     self.assertEqual(stats['m']['codeEvents'][1][1], 92)
     self.assertEqual(stats['m']['codeEvents'][1][3], '_func')
Exemple #27
0
 def testRequest(self):
     runner.run(self._func, "h", ("foo", "bar"), host=_HOST, port=_PORT)
     response = urllib.request.urlopen("http://%s:%s/profile" % (_HOST, _PORT))
     response_data = stats_server.decompress_data(response.read())
     stats = json.loads(response_data.decode("utf-8"))
     self.assertEqual(len(stats), 1)
     self.assertTrue("function _func" in stats["h"][0]["objectName"])
     self.assertDictEqual(stats["h"][0]["heatmap"], {"96": 1, "97": 1})
     self.assertListEqual(
         stats["h"][0]["srcCode"],
         [
             ["line", 95, "        def _func(foo, bar):\n"],
             ["line", 96, u"            baz = foo + bar\n"],
             ["line", 97, u"            return baz\n"],
         ],
     )
 def testRequest(self):
     runner.run(self._func, 'h', ('foo', 'bar'), host=_HOST, port=_PORT)
     response = urllib.request.urlopen('http://%s:%s/profile' %
                                       (_HOST, _PORT))
     response_data = stats_server.decompress_data(response.read())
     stats = json.loads(response_data.decode('utf-8'))
     self.assertTrue(stats['h']['runTime'] > 0)
     heatmaps = stats['h']['heatmaps']
     self.assertEqual(len(heatmaps), 1)
     self.assertTrue('function _func' in heatmaps[0]['name'])
     self.assertDictEqual(heatmaps[0]['executionCount'], {
         '102': 1,
         '103': 1
     })
     self.assertListEqual(heatmaps[0]['srcCode'],
                          [['line', 101, '        def _func(foo, bar):\n'],
                           ['line', 102, u'            baz = foo + bar\n'],
                           ['line', 103, u'            return baz\n']])