日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問(wèn) 生活随笔!

生活随笔

當(dāng)前位置: 首頁(yè) > 编程语言 > python >内容正文

python

安装python性能检测工具line_profiler

發(fā)布時(shí)間:2025/3/15 python 35 豆豆
生活随笔 收集整理的這篇文章主要介紹了 安装python性能检测工具line_profiler 小編覺(jué)得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.

line_profiler是一款監(jiān)測(cè)python的CPU密集型性能問(wèn)題的強(qiáng)大工具,可以對(duì)函數(shù)進(jìn)行逐行分析,在linux上安裝時(shí)一切正常,然而今天在win10 64位系統(tǒng)安裝失敗了

pip3 install line_profiler

報(bào)錯(cuò):

error: Microsoft Visual C++ 14.0 is required. Get it with "Microsoft Visual C++ Build Tools": http://landinghub.visualstudio.com/visual-cpp-build-tools

提示我需要安裝?Microsoft Visual C++ 14.0

解決辦法:

wheel是一個(gè)已經(jīng)編譯好的包,在安裝時(shí)不需要編譯過(guò)程,安裝whl文件時(shí)要比發(fā)布的源文件安裝要快,目前大部分python包都有wheel包,推薦使用wheel方式安裝

從https://www.lfd.uci.edu/~gohlke/pythonlibs/網(wǎng)站找到line_profiler,找到對(duì)應(yīng)的python版本,實(shí)測(cè)python3.6.4下win_32版本安裝不成功,使用win_amd64能成功安裝

簡(jiǎn)單測(cè)試:

kernprof -l -v tr1y.py

正常輸出如下:

(1.800000000000033, -1.800000000000033) length of x: 1000 total elements: 1000000 Wrote profile results to tr1y.py.lprof Timer unit: 5.68888e-07 sTotal time: 2.84954 s File: tr1y.py Function: calculate_z_serial_purepython at line 48Line # Hits Time Per Hit % Time Line Contents ==============================================================48 @profile49 def calculate_z_serial_purepython(max_iter, zs, cs):50 1 7062.0 7062.0 0.1 output = [0] * len(zs)51 1000001 564275.0 0.6 11.3 for i in range(len(zs)):52 1000000 553309.0 0.6 11.0 n = 053 1000000 632514.0 0.6 12.6 z = zs[i]54 1000000 593978.0 0.6 11.9 c = cs[i]55 1485000 1365751.0 0.9 27.3 while abs(z) < 2 and n < max_iter:56 485000 344250.0 0.7 6.9 z = z * z + c57 485000 310470.0 0.6 6.2 n += 158 1000000 637342.0 0.6 12.7 output[i] = n59 1 3.0 3.0 0.0 return output

?

轉(zhuǎn)載于:https://www.cnblogs.com/tarantino/p/10802072.html

總結(jié)

以上是生活随笔為你收集整理的安装python性能检测工具line_profiler的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問(wèn)題。

如果覺(jué)得生活随笔網(wǎng)站內(nèi)容還不錯(cuò),歡迎將生活随笔推薦給好友。