Usage: wrk <options> <url>                           

  Options:                                           
    -c, --connections <N>  Connections to keep open  
    -d, --duration    <T>  Duration of test          
    -t, --threads     <N>  Number of threads to use  
                                                     
    -s, --script      <S>  Load Lua script file      
    -H, --header      <H>  Add header to request     
        --latency          Print latency statistics  
        --timeout     <T>  Socket/request timeout    
    -v, --version          Print version details     
                                                
  Numeric arguments may include a SI unit (1k, 1M, 1G)
  Time arguments may include a time unit (2s, 2m, 2h)
<h2><a name="t0"></a><a id="jmeter_APP_0"></a>使用jmeter 对APP进行压力测试</h2>
[root@localhost /]#cd /tmp/
[root@localhost tmp]#tar –zxvf stress-1.0.4.tar.gz
# /static/ 下所有的请求都/usr/share/nginx/html下寻找资源
location /static/ {
	root /usr/share/nginx/html;
}
export JAVA_HOME=/usr/local/java/jdk1.8.0_181
export JRE_HOME=/usr/local/java/jdk1.8.0_181/jre
export CLASSPATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar:$JRE_HOME/lib:$CLASSPATH
export PATH=$JAVA_HOME/bin:$PATH
wget http://download.joedog.org/siege/siege-3.0.8.tar.gz
tar zxvf siege-3.0.8.tar.gz
cd siege-3.0.8
./configure
make
make install

验证安装结果:输入siege -V 如果输出了版本号就代表安装没问题
本次以centos7环境为例
yum install fio
{
    "access_token": "String",
    "token_type": "String",
    "refresh_token": "String",
    "expires_in": 43199,
    "scope": "ddd"
}
#!/bin/bash

filestr=$(pwd)/result/
time=$(date +"%Y%m%d-%H%M%S")
logname="ddr-$time.log"
tmpname="tmp-$time.log"
errname="err-$time.log"

pwdfile=$filestr$logname    #存储log
errfile=$filestr$errname    #存储err
tmpfile=$filestr$tmpname    #临时文件

# 定义一个函数来处理Ctrl+C信号  
myexit() {  
	pkill -9 stressapptest
	# 关闭脚本本身  
	rm $tmpfile $errfile -rf
    exit 1  
}  
  
setterm -blank 0

check=60                    #检测间隔

# 获取剩余内存大小(单位:字节)  
freemem=$(free -m | awk 'NR==2{print $4}')  
# 计算10个进程,每个进程测试的大小 
cont=10
testmem=$(echo "$freemem * 0.09" | bc)    

size=$(echo "$testmem" | cut -d '.' -f1)
  
# 判断传入的参数是否为数字  
if [[ $1 =~ ^-?[0-9]+$ ]]; then  
	#echo "参数是一个数字"  
	seco=$1
else  
	#echo "传入的参数不是一个数字"  
	seco=3600
fi

chmod 777 stressapptest

echo "Run cont:$cont stressapptest -M $size -s $seco" |tee -a  $pwdfile 
echo $(date) |tee -a  $pwdfile
echo "---------------------------------------------"  |tee -a $pwdfile
echo "---------------------------------------------"  |tee -a $pwdfile

for i in $(seq 1 $cont) 
do
	echo "OPEN stressapptest conts --->$i " |tee -a  $pwdfile
	./stressapptest -M $size -s $seco >> $pwdfile &
    sleep 1
done

# 注册 Ctrl+C 信号的处理函数  
trap myexit SIGINT  

sleep 10

free -m

for j in $(seq 1 $(($seco/$check))) 
do
    tail -2000  $pwdfile > $tmpfile
    grep "reread" $tmpfile > $errfile
	if [ $? -eq 0 ]; then
        rm $tmpfile -rf
		echo -------------------		|tee -a  $errfile
		echo -------------------		|tee -a  $errfile
		echo "DDR test is error!!!"		|tee -a  $errfile
		echo -------------------		|tee -a  $errfile
		echo -------------------		|tee -a  $errfile
        echo "Stressapptest is running for $(($j*$check)) seconds, DDR test is error!"  |tee -a  $errfile
		killall -9 stressapptest
		killall	sleep
        exit
	fi
    sleep $check
    echo "Stressapptest is running for $(($j*$check)) seconds"
done

sleep 60 

rm $tmpfile $errfile -rf

echo -------------------	|tee -a  $pwdfile
echo -------------------	|tee -a  $pwdfile
echo "DDR test is OK ^_^"	|tee -a  $pwdfile
echo -------------------	|tee -a  $pwdfile
echo -------------------	|tee -a  $pwdfile
Action()

{

         web_reg_save_param("return_code",

                  "LB=\"code\":",

                  "RB=,",

                  LAST);

   

         lr_start_transaction("发送请求事务");


         web_submit_data("web_submit_data",

                  "Action=https://www.xxxx.com/digitaldata/api/signer/1.0/signerRegist",

                  "Method=POST",

                  "TargetFrame=",

                  "Referer=",

        "RecContentType=application/json",

                  ITEMDATA,

                  "Name=signerName", "Value=xx", ENDITEM,

                  "Name=signerType", "Value=个人", ENDITEM,

                  "Name=country", "Value=cn", ENDITEM,

                  "Name=organization", "Value=xxx", ENDITEM,

                  "Name=organizationUnit", "Value=xxx", ENDITEM,

                  "Name=signerIDType", "Value=身份证", ENDITEM,

                  "Name=signerIDNo", "Value=xxx", ENDITEM,

                  LAST);


         lr_end_transaction("发送请求事务", LR_AUTO);

 
         if (atoi(lr_eval_string("{return_code}"))==1){

                  lr_output_message("操作成功");

         }

         else{

                  lr_output_message(lr_eval_string("{return_code}"));

         }

         return 0;

}
data=rp['2015-06-15':'2016-01-07']
import matplotlib.pyplot as plt
from pylab import mpl
mpl.rcParams['font.sans-serif']=['SimHei']
mpl.rcParams['axes.unicode_minus']=False
plt.plot(data)
plt.plot(data.index,np.zeros_like(data),'r--')
plt.xlabel('日期')
plt.ylabel('收益额')
plt.title('压力期间投资组合的收益额')
plt.grid()
[root]# redis-benchmark --help
Usage: redis-benchmark [-h <host>] [-p <port>] [-c <clients>] [-n <requests>] [-k <boolean>]

 -h <hostname>      Server hostname (default 127.0.0.1)
 -p <port>          Server port (default 6379)
 -s <socket>        Server socket (overrides host and port)
 -a <password>      Password for Redis Auth
 -c <clients>       Number of parallel connections (default 50)
 -n <requests>      Total number of requests (default 100000)
 -d <size>          Data size of SET/GET value in bytes (default 3)
 --dbnum <db>       SELECT the specified db number (default 0)
 -k <boolean>       1=keep alive 0=reconnect (default 1)
 -r <keyspacelen>   Use random keys for SET/GET/INCR, random values for SADD
  Using this option the benchmark will expand the string __rand_int__
  inside an argument with a 12 digits number in the specified range
  from 0 to keyspacelen-1. The substitution changes every time a command
  is executed. Default tests use this to hit random keys in the
  specified range.
 -P <numreq>        Pipeline <numreq> requests. Default 1 (no pipeline).
 -e                 If server replies with errors, show them on stdout.
                    (no more than 1 error per second is displayed)
 -q                 Quiet. Just show query/sec values
 --csv              Output in CSV format
 -l                 Loop. Run the tests forever
 -t <tests>         Only run the comma separated list of tests. The test
                    names are the same as the ones produced as output.
 -I                 Idle mode. Just open N idle connections and wait.

Examples:

 Run the benchmark with the default configuration against 127.0.0.1:6379:
   $ redis-benchmark

 Use 20 parallel clients, for a total of 100k requests, against 192.168.1.1:
   $ redis-benchmark -h 192.168.1.1 -p 6379 -n 100000 -c 20

 Fill 127.0.0.1:6379 with about 1 million keys only using the SET test:
   $ redis-benchmark -t set -n 1000000 -r 100000000

 Benchmark 127.0.0.1:6379 for a few commands producing CSV output:
   $ redis-benchmark -t ping,set,get -n 100000 --csv

 Benchmark a specific command line:
   $ redis-benchmark -r 10000 -n 10000 eval 'return redis.call("ping")' 0

 Fill a list with 10000 random elements:
   $ redis-benchmark -r 10000 -n 10000 lpush mylist __rand_int__

 On user specified command lines __rand_int__ is replaced with a random integer
 with a range of values selected by the -r option.
select * from table where id = #key# and pid=#key2#
select * from table where id = #key#
select * from table;
<div>
</div>                   
<br>
<a href="http://www.51testing.com/html/85/n-4458385.html"         
      target="_blank" >【调查报告】你以为的测试行业现状,其实是 
       这样的!
</a>
public class UserUtil {
	
	private static void createUser(int count) throws Exception{
		List<MiaoshaUser> users = new ArrayList<MiaoshaUser>(count);
		//生成用户
		for(int i=0;i<count;i++) {
			MiaoshaUser user = new MiaoshaUser();
			user.setId(13000000000L+i);
			user.setLoginCount(1);
			user.setNickname("user"+i);
			user.setRegisterDate(new Date());
			user.setSalt("1a2b3c");
			user.setPassword(Md5Util.inputPassToDbPass("123456", user.getSalt()));
			users.add(user);
		}
		System.out.println("create user");
		//插入数据库
		Connection conn = DBUtil.getConn();
		String sql = "insert into miaosha_user(login_count, nickname, register_date, salt, password, id)values(?,?,?,?,?,?)";
		PreparedStatement pstmt = conn.prepareStatement(sql);
		for(int i=0;i<users.size();i++) {
			MiaoshaUser user = users.get(i);
			pstmt.setInt(1, user.getLoginCount());
			pstmt.setString(2, user.getNickname());
			pstmt.setTimestamp(3, new Timestamp(user.getRegisterDate().getTime()));
			pstmt.setString(4, user.getSalt());
			pstmt.setString(5, user.getPassword());
			pstmt.setLong(6, user.getId());
			pstmt.addBatch();
		}
		pstmt.executeBatch();
		pstmt.close();
		conn.close();
		System.out.println("insert to db");
		//登录,生成token
		String urlString = "http://localhost:8080/login/do_login";
		File file = new File("D:/tokens.txt");
		if(file.exists()) {
			file.delete();
		}
		RandomAccessFile raf = new RandomAccessFile(file, "rw");
		file.createNewFile();
		raf.seek(0);
		for(int i=0;i<users.size();i++) {
			MiaoshaUser user = users.get(i);
			URL url = new URL(urlString);
			HttpURLConnection co = (HttpURLConnection)url.openConnection();
			co.setRequestMethod("POST");
			co.setDoOutput(true);
			OutputStream out = co.getOutputStream();
			String params = "mobile="+user.getId()+"&password="+Md5Util.inputPassToFormPass("123456");
			out.write(params.getBytes());
			out.flush();
			InputStream inputStream = co.getInputStream();
			ByteArrayOutputStream bout = new ByteArrayOutputStream();
			byte buff[] = new byte[1024];
			int len = 0;
			while((len = inputStream.read(buff)) >= 0) {
				bout.write(buff, 0 ,len);
			}
			inputStream.close();
			bout.close();
			String response = new String(bout.toByteArray());
			JSONObject jo = JSON.parseObject(response);
			String token = jo.getString("data");
			System.out.println("create token : " + user.getId());
			
			String row = user.getId()+","+token;
			raf.seek(raf.length());
			raf.write(row.getBytes());
			raf.write("\r\n".getBytes());
			System.out.println("write to file : " + user.getId());
		}
		raf.close();
		
		System.out.println("over");
	}
	
	public static void main(String[] args)throws Exception {
		createUser(5000);
	}
}
-A/--user-agent <string>          设置用户代理发送给服务器
-b/--cookie <name=string/file>    cookie字符串或文件读取位置
-c/--cookie-jar <file>            操作结束后把cookie写入到这个文件中
-C/--continue-at <offset>         断点续转
-D/--dump-header <file>           把header信息写入到该文件中
-d/--data <data>                  HTTP POST方式传送数据
-e/--referer                      来源网址
-f/--fail                         连接失败时不显示http错误
-H/--header <line>                自定义头信息传递给服务器
-o/--output                       把输出写到该文件中
-O/--remote-name                  把输出写到该文件中,保留远程文件的文件名
-r/--range <range>                检索来自HTTP/1.1或FTP服务器字节范围
-s/--silent                       静音模式。不输出任何东西
-T/--upload-file <file>           上传文件
-u/--user <user[:password]>       设置服务器的用户和密码
-w/--write-out [format]           什么输出完成后
-x/--proxy <host[:port]>          在给定的端口上使用HTTP代理
-X/--request <command>            指定什么命令
-v                                显示请求交互的详细信息
                                    * 表示 curl 任务;
                                    > 发送的信息;
                                    < 返回的信息
-#/--progress-bar                 进度条显示当前的传送状态
  • 1
  • 2
  • 3
  • 4
  • 5