예제 #1
0
 def testRequest(self):
     profiler.run(self._func, 'm', ('foo', 'bar'), host=_HOST, port=_PORT)
     response = urllib.request.urlopen('http://%s:%s/profile' %
                                       (_HOST, _PORT))
     stats = json.loads(response.read().decode('utf-8'))
     self.assertEqual(stats['m']['objectName'], '_func (function)')
     self.assertEqual(stats['m']['totalEvents'], 2)
예제 #2
0
파일: views.py 프로젝트: ahcheriet/vprof
def profile(request, uri):
    """Profiler handler."""
    if uri == '':
        profiler.run(show_guestbook, 'cmh', args=(request, ))
    elif uri == 'add':
        profiler.run(add_entry, 'cmh', args=(request, ))
    return http.HttpResponseRedirect(urlresolvers.reverse('show_guestbook'),
                                     request)
예제 #3
0
파일: views.py 프로젝트: carlosveliz/vprof
def profile(request, uri):
    """Profiler handler."""
    if uri == '':
        profiler.run(show_guestbook, 'cmh', args=(request,))
    elif uri == 'add':
        profiler.run(add_entry, 'cmh', args=(request,))
    return http.HttpResponseRedirect(
        urlresolvers.reverse('show_guestbook'), request)
예제 #4
0
 def testRequest(self):
     profiler.run(
         self._func, 'c', ('foo', 'bar'), host=_HOST, port=_PORT)
     response = urllib.request.urlopen(
         'http://%s:%s/profile' % (_HOST, _PORT))
     stats = json.loads(response.read().decode('utf-8'))
     self.assertEqual(stats['c']['objectName'], '_func (function)')
     self.assertEqual(stats['c']['totalCalls'], 2)
예제 #5
0
def profiler_handler(uri):
    """Profiler handler."""
    # HTTP method should be GET.
    if uri == 'main':
        profiler.run(show_guestbook, 'cmh')
    # In this case HTTP method should be POST singe add_entry uses POST
    elif uri == 'add':
        profiler.run(add_entry, 'cmh')
    return flask.redirect('/')
예제 #6
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))
     stats = json.loads(response.read().decode('utf-8'))
     self.assertEqual(len(stats), 1)
     self.assertTrue('function _func' in stats['h'][0]['objectName'])
     self.assertDictEqual(stats['h'][0]['heatmap'], {'118': 1, '119': 1})
     self.assertListEqual(stats['h'][0]['srcCode'],
                          [[117, '        def _func(foo, bar):\n'],
                           [118, u'            baz = foo + bar\n'],
                           [119, u'            return baz\n']])
예제 #7
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))
     stats = json.loads(response.read().decode('utf-8'))
     self.assertEqual(len(stats), 1)
     self.assertTrue('function _func' in stats['h'][0]['objectName'])
     self.assertDictEqual(
         stats['h'][0]['heatmap'], {'118': 1, '119': 1})
     self.assertListEqual(
         stats['h'][0]['srcCode'],
         [[117, '        def _func(foo, bar):\n'],
          [118, u'            baz = foo + bar\n'],
          [119, u'            return baz\n']])
예제 #8
0
    if args["distribution"]:
        if args["input"] == None:
            args["input"] = "polya.out"
        if args["outfile"] == None:
              args["outfile"] = "enum.in"
        if len(args["distribution"]) != 2:
            raise ValueError("The distribution option takes two arguments. The parameters the "
                             "distribution is over ('shape', 'conc', 'size', 'all') and the "
                             "number of structures desired. If all the structures are wanted "
                             "then the second argument should be 'all'.")
    if args["acceptrate"] and args["acceptrate"] is not None and (not isinstance(args["acceptrate"], float) or args["acceptrate"] > 1.0):
        raise ValueError(u"'-acceptrate' is to be a float less than 1.")

    if args["polya"]:
        _polya_out(args)
    if args["enum"] or (args["enum"] and args["distribution"]):
        _enum_out(args)
    if args["distribution"] and not args["enum"]:
        _enum_in(args)
    if args["visualize"]:
        _plot_HNFs(args,testmode=testmode)
        
if __name__ == '__main__':
    args = _parser_options()
    
    if args["profile"]:
        from vprof import profiler
        profiler.run(_script_enum, args["profile"], args=(args,), host='localhost', port=8000)
    else:
        _script_enum(args)
예제 #9
0
                "distribution is over ('shape', 'conc', 'size', 'all') and the "
                "number of structures desired. If all the structures are wanted "
                "then the second argument should be 'all'.")
    if args["acceptrate"] and args["acceptrate"] is not None and (
            not isinstance(args["acceptrate"], float)
            or args["acceptrate"] > 1.0):
        raise ValueError(u"'-acceptrate' is to be a float less than 1.")

    if args["polya"]:
        _polya_out(args)
    if args["enum"] or (args["enum"] and args["distribution"]):
        _enum_out(args)
    if args["distribution"] and not args["enum"]:
        _enum_in(args)
    if args["visualize"]:
        _plot_HNFs(args, testmode=testmode)


if __name__ == '__main__':
    args = _parser_options()

    if args["profile"]:
        from vprof import profiler
        profiler.run(_script_enum,
                     args["profile"],
                     args=(args, ),
                     host='localhost',
                     port=8000)
    else:
        _script_enum(args)
from vprof import profiler
profiler.run(word2vec_test, 'cmh')