前段時間項目壓測,看到開發命令行下使用這個命令進行壓測很是簡潔、方便,萌發了學習的興趣,這裏僅作簡單介紹。html
wrk支持大多數UNIX系統,不支持Windows。須要操做系統支持LuaJIT和OpenSSL。git
安裝:只須要從github上下載wrk源碼,在項目路徑下make便可。github
➜ ~ git clone https://github.com/wg/wrk Cloning into 'wrk'... remote: Enumerating objects: 1085, done. remote: Total 1085 (delta 0), reused 0 (delta 0), pack-reused 1085 Receiving objects: 100% (1085/1085), 27.42 MiB | 633.00 KiB/s, done. Resolving deltas: 100% (337/337), done. ➜ ~ cd wrk ➜ wrk git:(master) make Building LuaJIT... ==== Building LuaJI
編譯後,根目錄下會生成可執行文件wrk,能夠拷貝到PATH包含目錄中,或者直接將當前目錄添加到PATH,後續就能夠直接使用wrk命令。服務器
默認狀況下wrk會使用自帶的LuaJIT和OpenSSL。學習
指定使用系統已經安裝的版本以下:測試
make WITH_LUAJIT=/usr WITH_OPENSSL=/usr
➜ ~ wrk --help 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)
選項說明:ui
優勢:lua
缺點:url
支持lua腳本,詳見介紹見:<http://www.javashuo.com/article/p-pvxkjlei-cc.html操作系統