我正在对django rest框架api进行一些分析,并使用基于cprofile的分析中间件,得到了以下输出:
Sat Mar 2 23:55:13 2019 /var/folders/jr/something
41224 function calls (40529 primitive calls) in 0.182 seconds
Ordered by: internal time
ncalls tottime percall cumtime percall filename:lineno(function)
1 0.124 0.124 0.124 0.124 {built-in method _hashlib.pbkdf2_hmac}
11 0.006 0.001 0.007 0.001 {method 'execute' of 'psycopg2.extensions.cursor' objects}
252 0.003 0.000 0.003 0.000 {built-in method posix.stat}
11 0.002 0.000 0.009 0.001 /Users/my-local-user/.pyenv/versions/3.7.0/lib/python3.7/traceback.py:312(extract)
基于此,打电话
_hashlib.pbkdf2_hmac
一次一个请求几乎占用了我总执行时间的70%!
我还没有找到关于这个的大量信息,除了它在openssl中使用-但是我在本地运行时没有ssl。
为什么我花这么多时间在一个简单的api请求的加密函数中?