本文要推薦的[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);複製程式碼