zoukankan      html  css  js  c++  java
  • wrk 安装使用

    ==================== 安装 ====================
    https://github.com/wg/wrk/wiki

    sudo yum -y groupinstall 'Development Tools'
    sudo yum install -y openssl-devel git
    git clone https://github.com/wg/wrk.git wrk
    cd wrk
    make
    sudo cp wrk /usr/bin

    ==================== 使用 ====================

    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)

    wrk -c100 -t4 -d100s http://localhost:9981/api/test

    test.lua

    wrk.method="POST"

    wrk.body=[[ {"jsonKey": "jsonValue"} ]]

    wrk.headers["Content-Type"]="application/json; charset=utf-8"

    wrk -c100 -t4 -d100s -stest.lua --latency http://localhost:9981/api/test

    ==================== 测试结果 ====================

    Running 10s test @ http://localhost:9981/api/test
      4 threads and 1000 connections                    // 线程数设置为cpu核心数或其2倍,设置不同的连接数以观察吞吐量及响应时间情况
      Thread Stats   Avg      Stdev     Max   +/- Stdev // 每条线程的状态
        Latency    70.08ms    8.76ms 127.28ms   81.70%  // 完成一个请求所需要的响应时间
        Req/Sec     3.55k   581.40     4.91k    68.50%  // 每秒完成的请求数
      Latency Distribution
         50%   68.65ms
         75%   72.67ms
         90%   80.40ms
         99%   99.73ms                                  // 99%的请求完成一个请求所需要的响应时间
      141270 requests in 10.05s, 265.27MB read          // 规定时间内总请求数及传送数据量
    Requests/sec:  14053.75                             // 每秒总共可以完成的请求数
    Transfer/sec:     26.39MB                           // 每秒总共传送数据量

     

    wrk -c100 -t4 -d100s -stest.lua --latency http://localhost:9981/api/test

  • 相关阅读:
    PAT 1097. Deduplication on a Linked List (链表)
    PAT 1096. Consecutive Factors
    PAT 1095. Cars on Campus
    PAT 1094. The Largest Generation (层级遍历)
    PAT 1093. Count PAT's
    PAT 1092. To Buy or Not to Buy
    PAT 1091. Acute Stroke (bfs)
    CSS:word-wrap/overflow/transition
    node-webkit中的requirejs报错问题:path must be a string error in Require.js
    script加载之defer和async
  • 原文地址:https://www.cnblogs.com/xiayudashan/p/9645680.html
Copyright © 2011-2022 走看看