我如何衡量我的Flask项目的哪些部分占用了太多的处理器时间?以及如何减少它?如果需要,我会添加代码,但它有点大代码。到目前为止它需要50-100%的处理器。 (我使用了命令top
)
好的,我使用from werkzeug.contrib.profiler import ProfilerMiddleware
来分析
这是我在浏览器中打开索引页面时分析器的结果,这是最慢的功能。有什么帮助吗?
PATH: '/auth/login'
47946 function calls (44288 primitive calls) in 0.232 seconds
Ordered by: internal time, call count
List reduced from 618 to 25 due to restriction <25>
ncalls tottime percall cumtime percall filename:lineno(function)
1 0.033 0.033 0.043 0.043 /home-fri/hojny/.virtualenvs/e-vzd elavanie/local/lib/python2.7/site-packages/jinja2/ext.py:12()
638/29 0.018 0.000 0.040 0.001 /home-fri/hojny/.virtualenvs/e-vzd elavanie/local/lib/python2.7/site-packages/jinja2/nodes.py:184(find_all)
364 0.017 0.000 0.018 0.000 /home-fri/hojny/.virtualenvs/e-vzd elavanie/local/lib/python2.7/site-packages/jinja2/lexer.py:230(new)
18 0.017 0.001 0.020 0.001 /home-fri/hojny/.virtualenvs/e-vzd elavanie/local/lib/python2.7/site-packages/jinja2/compiler.py:1212(visit_Output)
75 0.016 0.000 0.017 0.000 /home-fri/hojny/.virtualenvs/e-vzd elavanie/local/lib/python2.7/site-packages/jinja2/lexer.py:538(_normalize_newlin es)
4705 0.014 0.000 0.016 0.000 /home-fri/hojny/.virtualenvs/e-vzd elavanie/local/lib/python2.7/site-packages/jinja2/nodes.py:148(iter_fields)
2734 0.013 0.000 0.032 0.000 /home-fri/hojny/.virtualenvs/e-vzd elavanie/local/lib/python2.7/site-packages/jinja2/nodes.py:164(iter_child_nodes)
467 0.012 0.000 0.019 0.000 /home-fri/hojny/.virtualenvs/e-vzd elavanie/local/lib/python2.7/site-packages/jinja2/lexer.py:593(tokeniter)
210/2 0.010 0.000 0.015 0.007 /home-fri/hojny/.virtualenvs/e-vzd elavanie/local/lib/python2.7/site-packages/jinja2/visitor.py:58(generic_visit)
1 0.010 0.010 0.010 0.010 /home-fri/hojny/.virtualenvs/e-vzd elavanie/local/lib/python2.7/site-packages/jinja2/ext.py:41(Extension)
8925 0.007 0.000 0.007 0.000 {isinstance}
1713 0.005 0.000 0.005 0.000 {method 'match' of '_sre.SRE_Patte rn' objects}
4315 0.004 0.000 0.004 0.000 {getattr}
998/4 0.003 0.000 0.093 0.023 /home-fri/hojny/.virtualenvs/e-vzd elavanie/local/lib/python2.7/site-packages/jinja2/visitor.py:34(visit)
540/68 0.002 0.000 0.013 0.000 /home-fri/hojny/.virtualenvs/e-vzd elavanie/local/lib/python2.7/site-packages/jinja2/visitor.py:41(generic_visit)
206 0.002 0.000 0.003 0.000 /home-fri/hojny/.virtualenvs/e-vzd elavanie/local/lib/python2.7/site-packages/jinja2/nodes.py:127(init)
362 0.002 0.000 0.056 0.000 /home-fri/hojny/.virtualenvs/e-vzd elavanie/local/lib/python2.7/site-packages/jinja2/lexer.py:548(wrap)
998 0.002 0.000 0.003 0.000 /home-fri/hojny/.virtualenvs/e-vzd elavanie/local/lib/python2.7/site-packages/jinja2/visitor.py:26(get_visitor)
2 0.002 0.001 0.002 0.001 {compile}
575 0.001 0.000 0.002 0.000 /home-fri/hojny/.virtualenvs/e-vzd elavanie/local/lib/python2.7/site-packages/jinja2/lexer.py:240(test)
748/386 0.001 0.000 0.058 0.000 {next}
78/9 0.001 0.000 0.002 0.000 /home-fri/hojny/.virtualenvs/e-vzd elavanie/lib/python2.7/sre_compile.py:32(_compile)
45/10 0.001 0.000 0.004 0.000 /home-fri/hojny/.virtualenvs/e-vzd elavanie/lib/python2.7/sre_parse.py:388(_parse)
364 0.001 0.000 0.002 0.000 /home-fri/hojny/.virtualenvs/e-vzd elavanie/local/lib/python2.7/site-packages/jinja2/compiler.py:492(write)
42 0.001 0.000 0.001 0.000 /home-fri/hojny/.virtualenvs/e-vzd elavanie/local/lib/python2.7/site-packages/werkzeug/urls.py:441(url_quote)