live-forum/server/k6/run-single-api.bat
2026-03-24 11:27:37 +08:00

66 lines
1.9 KiB
Batchfile
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

@echo off
chcp 65001 >nul
echo ========================================
echo 直播论坛 - k6 压测
echo 场景:单接口极限压测
echo ========================================
echo.
REM 检查k6是否安装
where k6 >nul 2>nul
if %ERRORLEVEL% neq 0 (
echo [错误] 未找到 k6请先安装 k6
echo 安装方法:
echo Windows: choco install k6
echo 或从 https://k6.io/docs/get-started/installation/ 下载
pause
exit /b 1
)
REM 检查tokens.txt是否有内容
findstr /v /r "^#" tokens.txt | findstr /r "." >nul 2>nul
if %ERRORLEVEL% neq 0 (
echo [警告] tokens.txt 中没有有效的 Token
echo 请先在 tokens.txt 中添加 Token每行一个
pause
exit /b 1
)
echo Token文件检查通过
echo.
echo 可选的接口名称:
echo [读接口]
echo - GetPosts : 帖子列表
echo - GetPostDetail : 帖子详情
echo - GetPostComments : 评论列表
echo - Rankings : 主播榜单
echo - RankingsMore : 更多排行
echo - LiveStreamers : 直播列表
echo - GetUserInfo : 用户信息
echo - Banners : 轮播图
echo - GetMessages : 消息列表
echo.
echo [写接口]
echo - LikePost : 帖子点赞
echo - LikeComment : 评论点赞
echo.
set /p API_NAME="请输入接口名称 (默认 GetPosts): "
if "%API_NAME%"=="" set API_NAME=GetPosts
set /p QUICK="是否进行快速测试?(y/n默认n): "
if /i "%QUICK%"=="y" (
echo 启动快速测试模式,测试接口: %API_NAME%
k6 run --out web-dashboard -e QUICK_TEST=true -e API_NAME=%API_NAME% scenario-single-api.js
) else (
echo 启动正式压测模式,测试接口: %API_NAME%
k6 run --out web-dashboard -e API_NAME=%API_NAME% scenario-single-api.js
)
echo.
echo ========================================
echo 压测结束
echo Web Dashboard: http://127.0.0.1:5665
echo ========================================
pause