当前位置: 首页 > 工具软件 > mechanize > 使用案例 >

python压力测试框架_multi_mechanize开源python压力测试框架

宿洋
2023-12-01

因为工作需要,需要自己做压力测试,然后就寻找免费的测试框架,然后说python不错,然后就找到了这个基于python的测试框架multi_mechanize。

然后在网上搜了下关于这个multi_mechanize的东西,发现资料比较少,然后就找到这玩意的官网,搜集点资料,在自己机器上也试安装了下。发现还是蛮酷的。

下面介绍下安装过程,当然这是基于linux的,我是用cygwin安装的

先安装python,这个这里省略,搜下应该是一大堆资料

安装 setup模块

wget http://peak.telecommunity.com/dist/ez_setup.py

python ez_setup.py

去http://testutils.org/multi-mechanize/#examples下载Multi-Mechanize

上面还有文档,已经怎么开始自己的test script

解压

cd 到

cd multi-mechanize-1.2.0/

python setup.py install

创建测试项目,

multimech-newproject my_project

multimech-run my_project

$ multimech-run my_project

ERROR: can not import Matplotlib. install Matplotlib to generate graphs

user_groups:  2

threads: 6

[================100%==================]  30s/30s   transactions: 114  timers: 114  errors: 0

analyzing results...

transactions: 115

errors: 0

test start: 2013-03-04 15:09:00

test finish: 2013-03-04 15:09:27

Traceback (most recent call last):

File "/usr/bin/multimech-run", line 8, in

load_entry_point('multi-mechanize==1.2.0', 'console_scripts', 'multimech-run')()

File "/usr/lib/python2.6/site-packages/multi_mechanize-1.2.0-py2.6.egg/multimechanize/utilities/run.py", line 64, in main

run_test()

File "/usr/lib/python2.6/site-packages/multi_mechanize-1.2.0-py2.6.egg/multimechanize/utilities/run.py", line 131, in run_test

results.output_results(output_dir, 'results.csv', run_time, rampup, results_ts_interval, user_group_configs, xml_report)

File "/usr/lib/python2.6/site-packages/multi_mechanize-1.2.0-py2.6.egg/multimechanize/results.py", line 65, in output_results

graph.resp_graph_raw(trans_timer_points, 'All_Transactions_response_times.png', results_dir)

File "/usr/lib/python2.6/site-packages/multi_mechanize-1.2.0-py2.6.egg/multimechanize/graph.py", line 23, in resp_graph_raw

fig = figure(figsize=(8, 3.3))  # image dimensions

NameError: global name 'figure' is not defined

这里会提示没有Matplotlib包,用来绘制结果图

安装Matplotlib包

需要先安装numpy  而安装numpy需要用到pip命令 于是一步步来安装

wget http://pypi.python.org/packages/source/p/pip/pip-0.2.1.tar.gz

tar xzf pip-0.2.1.tar.gz

cd pip-0.2.1/

python setup.py install

pip install numpy

cd matplotlib-1.2.0/

python setup.py install

好了 等安装完 再运行

multimech-newproject my_project

multimech-run my_project

就会运行成功

$ multimech-run my_project/

user_groups:  2

threads: 6

[================100%==================]  30s/30s   transactions: 117  timers: 117  errors: 0

analyzing results...

transactions: 119

errors: 0

test start: 2013-03-04 17:04:49

test finish: 2013-03-04 17:05:17

created: ./my_project//results/results_2013.03.04_17.04.47/results.html

done.

在/my_project//results/results_2013.03.04_17.04.47/results.html 目录下就能看到测试的结果了。

如果要实现自己的测试案例  就按照官网上的文档来一步一步走就行了

 类似资料: