2015-09-25 5 views
0

Я хотел бы написать вывод profilehooks в .prof-файл. Чтобы преобразовать файл в файл qcachgrind и визуализировать результаты профилирования. (Я не могу использовать Cprofile в Cprofile, не профилировать код)can profilehooks, писать .prof файлы?

+0

Я предполагаю, что вы делаете это, чтобы ускорить код. Вы понимаете, что образцы стека выставляют ускорения [* без необходимости их измерения. *] (Http://stackoverflow.com/a/4299378/23771) Они находят по крайней мере столько же, сколько профилировщики (детерминированные или статистические). –

ответ

0

Его не в сети, но документация говорит:

profile(fn=None, skip=0, filename=None, immediate=False, dirs=False, sort=None, entries=40, profiler=('cProfile', 'profile', 'hotshot'), stdout=True) 
    Mark `fn` for profiling. 

    If `skip` is > 0, first `skip` calls to `fn` will not be profiled. 

    If `immediate` is False, profiling results will be printed to 
    sys.stdout on program termination. Otherwise results will be printed 
    after each call. (If you don't want this, set stdout=False and specify a 
    `filename` to store profile data.) 

    If `dirs` is False only the name of the file will be printed. 
    Otherwise the full path is used. 

    `sort` can be a list of sort keys (defaulting to ['cumulative', 
    'time', 'calls']). The following ones are recognized:: 

     'calls'  -- call count 
     'cumulative' -- cumulative time 
     'file'  -- file name 
     'line'  -- line number 
     'module'  -- file name 
     'name'  -- function name 
     'nfl'  -- name/file/line 
     'pcalls'  -- call count 
     'stdname' -- standard name 
     'time'  -- internal time 

    `entries` limits the output to the first N entries. 

    `profiler` can be used to select the preferred profiler, or specify a 
    sequence of them, in order of preference. The default is ('cProfile'. 
    'profile', 'hotshot'). 

    If `filename` is specified, the profile stats will be stored in the 
    named file. You can load them with pstats.Stats(filename) or use a 
    visualization tool like RunSnakeRun. 

    Usage:: 

     def fn(...): 
      ... 
     fn = profile(fn, skip=1) 

    If you are using Python 2.4, you should be able to use the decorator 
    syntax:: 

     @profile(skip=3) 
     def fn(...): 
      ... 

    or just :: 

     @profile 
     def fn(...): 
      ... 
Смежные вопросы