python开发性能测试工具_安装python性能检测工具line_profiler

line_profiler是一款监测python的CPU密集型性能问题的强大工具,可以对函数进行逐行分析,在linux上安装时一切正常,然而今天在win10 64位系统安装失败了

pip3 install line_profiler

报错:

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是一个已经编译好的包,在安装时不需要编译过程,安装whl文件时要比发布的源文件安装要快,目前大部分python包都有wheel包,推荐使用wheel方式安装

从https://www.lfd.uci.edu/~gohlke/pythonlibs/网站找到line_profiler,找到对应的python版本,实测python3.6.4下win_32版本安装不成功,使用win_amd64能成功安装

简单测试:

kernprof -l -v tr1y.py

正常输出如下:

(1.800000000000033, -1.800000000000033)

length of x:1000total elements:1000000Wrote profile results to tr1y.py.lprof

Timer unit:5.68888e-07s

Total time:2.84954s

File: tr1y.py

Function: calculate_z_serial_purepython at line48Line#Hits Time Per Hit % Time Line Contents

==============================================================

48@profile49 defcalculate_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 inrange(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 <56 z="z" n>

58 1000000 637342.0 0.6 12.7 output[i] =n59 1 3.0 3.0 0.0 return output

56>
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值