線上壓力測試工具-程式設計師線上工具網

王三金發表於2018-12-04

      本文要推薦的[ToolFk]是一款程式設計師經常使用的線上免費測試工具箱,ToolFk 特色是專注於程式設計師日常的開發工具,不用安裝任何軟體,只要把內容貼上按一個執行按鈕,就能獲取到想要的內容結果。ToolFk還支援 BarCode條形碼線上生成QueryList採集器PHP程式碼線上執行PHP混淆、加密、解密Python程式碼線上執行JavaScript線上執行YAML格式化工具HTTP模擬查詢工具HTML線上工具箱JavaScript線上工具箱CSS線上工具箱JSON線上工具箱Unixtime時間戳轉換Base64/URL/Native2Ascii轉換CSV轉換工具箱XML線上工具箱WebSocket線上工具Markdown 線上工具箱Htaccess2nginx 轉換進位制線上轉換線上加密工具箱線上偽原創工具線上APK反編譯線上網頁截圖工具線上隨機密碼生成線上生成二維碼Qrcode線上Crontab表示式生成線上短網址生成線上計算器工具Linux常用命令大全線上文字比較工具線上思維導圖工具線上資料庫設計工具免費CDN加速服務線上壓力測試工具。等20多個日常程式設計師開發工具,算是一個非常全面的程式設計師工具箱網站。


網站名稱:ToolFk
網站鏈結:www.toolfk.com/
工具連結:www.toolfk.com/tool-online…

程式碼教學

本工具[線上壓力測試工具]依賴的程式碼庫為 https://github.com/rakyll/hey

STEP 1

線上壓力測試工具-程式設計師線上工具網

STEP 2

核心程式碼如下

 #-n Number of requests to run. Default is 200.
 $number_n   =   intval(request('n',200));
 $number_n   =   $number_n>10000?10000:$number_n;
 $number_n   =   $number_n<10?10:$number_n;

 $cmd       .=   " -n {$number_n}";

 #-c Number of requests to run concurrently. Total number of requests cannot be smaller than the concurrency level. Default is 50.
 $number_c   =   intval(request('c',50));
 $number_c   =   $number_c>1000?1000:$number_c;
 $number_c   =   $number_c<10?10:$number_c;
 $cmd       .=   " -c {$number_c}";

 #Rate limit, in queries per second (QPS). Default is no rate limit. (速率限制)
 $number_q   =   intval(request('q',0));
 $number_q   =   $number_q>1000?1000:$number_q;
 $number_q   =   $number_q<0?0:$number_q;
 if($number_q){
     $cmd   .=   " -q {$number_q}";
 }


 #-z 執行多久時間
 $number_z   =   intval(request('z',0));//10s,3m
 $number_z   =   $number_z>60?60:$number_z; #最多60s
 $number_z   =   $number_z<0?0:$number_z;
 if($number_z){
     $cmd   .=   " -z {$number_z}";
 }

 #-m  HTTP method, one of GET, POST, PUT, DELETE, HEAD, OPTIONS.
 $number_m   =   request('m','GET');//GET,POST
 if(!in_array($number_m,["GET","POST"])){
     $number_m = "GET";
 }

 $cmd       .=   " -m {$number_m}";


 # -t  Timeout for each request in seconds. Default is 20, use 0 for infinite.
 $number_t   =   intval(request('t',20));
 $number_t   =   $number_t>60?60:$number_t; #最多60s
 $number_t   =   $number_t<0?0:$number_t;

 if($number_t){
     $cmd   .=   " -t {$number_t}";
 }


 # -T  Content-type, defaults to "text/html".
 $number_T     =   request('T',"text/html");
 if(!in_array($number_T,["text/html","application/json","multipart/form-data"])){
     $number_T = "text/html";
 }

 $cmd         .=   " -T {$number_T}";


 #  -d  HTTP request body.
 $number_d     =   request('d');
 if($number_m == "POST"){
     $cmd   .=   " -d {$number_d}";
 }

// \App\Helper\UtilsHelper::log_debug("CMD",$cmd);
 $cmd         .= " 2>&1";
 $content      =   shell_exec($cmd);複製程式碼



相關文章