码迷,mamicode.com
首页 > 其他好文 > 详细

day02

时间:2017-12-22 22:51:56      阅读:199      评论:0      收藏:0      [点我收藏+]

标签:range   ever   自动   用户   网络   运行   and   des   output   

1、jmeter压测

  tps:每秒钟处理事务数

  qps:

  响应时间:打开时间

2、压测获取个人信息:小黑,看聚合报告

线程组右键--添加--监听器--聚合报告--线程组点击--永远--持续时间;30秒

Samples:多少个请求

Average:响应时间

Throughput:tps

3、linux下运行jemeter脚本

linux下运行jmeter是在jmeter的bin目录下的jmeter.sh这个shell脚本。

sh jmeter.sh -n –t a.jmx -l res.jtl

-n代表以没有图形化界面启动

-t代表后面是测试脚本

a.jmx也就是我们做好的jmeter脚本

-l代表测试结果

res.jtl就是测试结果文件,jemer的聚合报告中点击浏览

查看结果的话,在查看结果树视图中导入这个res.jtl就可以查看到测试结果了

 4、jmeter添加压力机

首先要在做压力机的机子上启动jmeter的代理,然后做为控制机的机子上添加上压力机的ip即可。

Jmeter的bin目录下有一个jmeter-server,启动它即可,windows机子作为压力机的话,运行jmeter-sever.bat,linux作为压力机的话,运行jmeter-server。

然后在作为控制机的jmeter配置文件里添加压力机ip即可,jmeter的配置文件在bin目录下jmeter.properties,添加压力机的时候,在配置文件里面找到remote_hosts添加ip,然后重启jmeter就可以看到远程压力机了,运行中有远程启动跟远程全部启动

5、charles

1)抓web端的http的,https的是安全的,加密的,部分可以抓到,网上有教程

2)移动端的,设置下代理,前提是手机的wifi跟电脑是在同一个网段中,

ip:点击网络--打开网络和共享中心--无限网络--详细信息--IPv4地址

3)过滤

Sequence--Filter--输入baidu

4)拦截客户端到服务端的请求跟响应,进行修改

修改请求:

拦截网址右键--Breakpoints--刷新页面--Breakpoints中有个Ddit  Request--修改参数--Execute

修改返回:

拦截网址右键--Breakpoints--刷新页面--Execute--Edit Response--Text--随便修改--Execute--Execute--Execute

                                                                             Edit Response--HTML--全部删除,改为hahahahha--Execute--Execute--Execute

 抓到的数据,如果返回的没有问题,那就是前端展示的问题

5、jemeter下载文件

Http请求--百度中找个图片,复制图片地址--名称:下载文件---ip:timgsa.baidu.com--https--/timg?image&quality=80&...--查看结果树

存放图片:

线程组右键--添加--Sampler--Bean Shell Sampler--Script(sed below for variables that are defined)

import java.io.*;

byte[] result = prev.getResponseData();  //这个是获取到请求返回的数据,prev是获取上个请求的返回
String file_name = "C:\\Users\\bjniuhanyang\\Desktop\\BaiDu.jpg"; //代表存放文件的位置和文件名
File file = new File(file_name);
FileOutputStream out = new FileOutputStream(file);
out.write(result);
out.close();
6、python开始啦~~~

自动化测试  --写的代码帮你测试。
计算机只认识2进制 0 1
编译型语言
代码在编译之后,编译成2进制的文件,然后计算机就可用运行了。
c、c++、c#
解释型语言
它是在运行的时候才编译的。
python、php、shell、ruby、js、java
print(‘hello world!‘)

脚本语言
指这个语言只有一个单一的功能。
shell、js、
数据挖掘(爬虫)、数据分析、自动化运维、自动化测试、后台服务接口、ai、人工智能、嵌入式、web开发

 7、if else

username = input(‘请输入您的用户名:‘)
passwd = input(‘请输入您的密码:‘)
if username == ‘yanzhifei‘ and passwd == ‘123456‘:
print (‘欢迎光临‘)
else:
print (‘账号/密码错误‘)

 8、成绩脚本

score = int(input(‘请输入你的分数:‘))

#input接收到的全部是str类型
# score = int(score)
if score<60:
print (‘不及格‘)
if score>50:
print(‘hahaha‘)
elif score<50:
print(‘小傻瓜‘)
else:
print(‘----------‘)
elif score>=60 and score <80:
print (‘及格‘)
elif score>=80 and score<90:
print (‘良好‘)
else:
print(‘优秀‘)

 9、循环、迭代、遍历

for循环
while
循环就是重复的去干嘛
指定一个循环结束条件
用while循环的,那么必须得有计数器
continue 结束本次循环,继续下一次循环
break 结束循环
count = 0
while count<10:
print(‘哈哈哈哈哈‘,count+1)
# count = count+1
count+=1
break
else:
print(‘done‘)

 10、count = 0 #计数器

while count<3:
username = input(‘ples enter your username: ‘)
pwd = input(‘ples enter your pwd: ‘)
if username == ‘yzf‘ and pwd == ‘123456‘:
print (‘欢迎光临‘,count+1)
continue
else:
print(‘账号/密码错误:‘,count+1)
count+=1
else:
print(‘错误次数过多‘,count+1)

 11、# 猜数字:

import random
random_num= random.randint(1,1000)
print(random_num)
count = 0
while count<7:
count += 1
num = int(input(‘请输入你猜的数字:‘))
if num>random_num:
print(‘你猜大了‘)
continue
elif num<random_num:
print(‘太小了‘)
continue
else:
print(‘恭喜你猜对了,答案是:‘,random_num)
break

 12、for循环

# for i in range(5):
# print (‘哈哈哈‘,i+1)
for i in range(5):
username = input(‘请输入你的名字:‘)
time = 123
# print(username+‘,欢迎光临‘+‘时间是:‘+time)
# print(‘%s,欢迎光临,时间是:%.2f‘ % (username,time))
# print(
# ‘{},欢迎光临,时间是:{},明天时间是{date}‘.format(username, time)
# )
print(
‘{name},欢迎光临,时间是:{date},明天时间是{date}‘.format(name=username,date=time)
)

 

 

 

 

作业:

1、写一个登录的程序,登录成功之后,提示xxx欢迎登录,登录失败次数是3次,你要校验一下输入为空的情况,为空的情况也算失败一次。
什么也不输入,输入空格的
http://www.nnzhp.cn/archives/162 
2、输入一个数字,产生多少条电话号码,够11位数字就行,生成11位的手机号码,写到文件里面
http://www.nnzhp.cn/archives/160

http://www.runoob.com/python/python-files-io.html 
http://www.nnzhp.cn/archives/160

 

day02

标签:range   ever   自动   用户   网络   运行   and   des   output   

原文地址:http://www.cnblogs.com/zfzhp/p/8053996.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!