[性能测试]Python性能测试

环境:Linux
以下几个工具都是基于FlameGraph (http://www.brendangregg.com/flamegraphs.html)来展开的。

首先安装python-flamegraph

https://github.com/evanhempel/python-flamegraph

pip/ pip3 install git+https://github.com/evanhempel/python-flamegraph.git
cd pyflame
./autogen.sh
./configure
此时运行make命令会出现提示:
Making all in src
make[1]: Entering directory `/root/pyflame/src'
make  all-am
make[2]: Entering directory `/root/pyflame/src'
make[2]: Leaving directory `/root/pyflame/src'
make[1]: Leaving directory `/root/pyflame/src'
make[1]: Entering directory `/root/pyflame'
make[1]: Nothing to be done for `all-am'.
make[1]: Leaving directory `/root/pyflame'
不用管它。
继续运行:
make check
会提示以下
Making check in src
make[1]: Entering directory `/root/pyflame/src'
make[1]: Leaving directory `/root/pyflame/src'
make[1]: Entering directory `/root/pyflame'
make[1]: Nothing to be done for `check-am'.
make[1]: Leaving directory `/root/pyflame'
./runtests.sh -v
make: *** [check] Error 1
继续不用管
运行 make install
提示:
Making install in src
make[1]: Entering directory `/root/pyflame/src'
make[2]: Entering directory `/root/pyflame/src'
 /usr/bin/mkdir -p '/usr/local/bin'
  /bin/sh ../libtool   --mode=install /usr/bin/install -c pyflame '/usr/local/bin'
libtool: install: /usr/bin/install -c pyflame /usr/local/bin/pyflame
make[2]: Nothing to be done for `install-data-am'.
make[2]: Leaving directory `/root/pyflame/src'
make[1]: Leaving directory `/root/pyflame/src'
make[1]: Entering directory `/root/pyflame'
make[2]: Entering directory `/root/pyflame'
make[2]: Nothing to be done for `install-exec-am'.
 /usr/bin/mkdir -p '/usr/local/share/man/man1'
 /usr/bin/install -c -m 644 'docs/pyflame.man' '/usr/local/share/man/man1/pyflame.1'
make[2]: Leaving directory `/root/pyflame'
make[1]: Leaving directory `/root/pyflame'
此时要注意了:
此时运行提示里的:
/usr/bin/mkdir -p '/usr/local/bin'
/usr/bin/install -c pyflame /usr/local/bin/pyflame   
即可安装成功
运行以下命令如果有输出即安装成功
pyflame -t python -c 'print(sum(i for i in range(100000)))'
4999950000  

接下来安装FlameGraph

wget https://github.com/brendangregg/FlameGraph/archive/master.zip
unzip master.zip
mv FlameGraph-master/ /opt/FlameGraph
export PATH=$PATH:/opt/FlameGraph
cd /opt/FlameGraph
cp flamegraph.pl /usr/local/bin
flamegraph.pl -h
如果有以下输出,则安装成功
Option h is ambiguous (hash, height, help)
USAGE: /usr/local/bin/flamegraph.pl [options] infile > outfile.svg

	--title TEXT     # change title text
	--subtitle TEXT  # second level title (optional)
	--width NUM      # width of image (default 1200)
	--height NUM     # height of each frame (default 16)
	--minwidth NUM   # omit smaller functions (default 0.1 pixels)
	--fonttype FONT  # font type (default "Verdana")
	--fontsize NUM   # font size (default 12)
	--countname TEXT # count type label (default "samples")
	--nametype TEXT  # name type label (default "Function:")
	--colors PALETTE # set color palette. choices are: hot (default), mem,
	                 # io, wakeup, chain, java, js, perl, red, green, blue,
	                 # aqua, yellow, purple, orange
....
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值