当前位置:网站首页>动态模型中嵌入静态模型实践
动态模型中嵌入静态模型实践
2022-08-01 14:10:00 【InfoQ】
- 设置步长
- 增减步长
- 终止测试
思路
private class FunTester implements IFunController {
boolean inputKey = true;
/**
* 控制
*/
boolean autoKey = false
@Override
public void run() {
while (inputKey) {
String input = getInput();
switch (input) {
case "+":
add();
break;
case "-":
reduce();
break;
case "*":
over();
break;
case "/":
autoKey = true
break;
default:
if (Regex.isMatch(input, "(F|f)\\d+")) QPS_STEP = changeStringToInt(input.substring(1));
if (Regex.isMatch(input, "(T|t)\\d+(D|d)\\d+")) {
def split = (input - "T" - "t").split(/(d|D)/)
autoTarget(split[0] as int, split[1] as int)
}
if (Regex.isMatch(input, "(A|a)-{0,1}\\d+(D|d)\\d+")) {
def split = (input - "A" - "a").split(/(d|D)/)
autoAdd(split[0] as int, split[1] as int)
}
break;
}
}
}
/**
* 自动控制递增功能,以目标值计算
* @param target 目标QPS
* @param duration 持续时间
* @return
*/
def autoTarget(int target, duration) {
fun {
for (i in 0..<duration) {
if (autoKey) break
qps += (target - qps) / duration
sleep(1.0)
}
if (!autoKey) qps = target
autoKey = false
}
}
/**
* 自动控制递增功能,以增加值计算
* @param sum
* @param duration
* @return
*/
def autoAdd(int sum, duration) {
fun {
int q = qps
for (i in 0..<duration) {
if (autoKey) break
qps += sum / duration
sleep(1.0)
}
if (!autoKey) qps = q + sum
autoKey = false
}
}
@Override
public void add() {
qps += QPS_STEP
}
@Override
public void reduce() {
qps -= QPS_STEP
if (qps < 1) over()
}
@Override
public void over() {
inputKey = false
key = false
logger.info("动态结束任务!");
}
}
/
- 性能测试专题
- Java、Groovy、Go、Python
- 单测&白盒
- FunTester社群风采
- 测试理论鸡汤
- 接口功能测试专题
- FunTester视频专题
- 案例分享:方案、BUG、爬虫
- UI自动化专题
- 测试工具专题
阅读原文,跳转我的仓库地址
边栏推荐
猜你喜欢
随机推荐
170页6万字智慧能源管理平台建设方案书
win10+Qt5.15.2 realizes low-power bluetooth control
kubernetes之DaemonSet以及滚动更新
openEuler 社区12位开发者荣获年度开源贡献之星
PAT1165 Block Reversing(25)
直播系统聊天技术(八):vivo直播系统中IM消息模块的架构实践
易优压双驱挖掘机压路机器类网站源码 v1.5.8
lua脚本关键
Typora报错:This beta version of Typora is expired
什么是混合元编程
重磅!国内首个开放式在线绘图平台Figdraw突破10万用户!发布《奖学金激励计划》:最高5000元!...
十九届浙大城院程序设计竞赛 F.Sum of Numerators(数学/找规律)
模型运营是做什么的(概念模型数据库)
视频传输协议(常用的视频协议)
The problem that the column becomes indexed after pd groupby and the aggregation column has no column name
final关键字的作用 final和基本类型、引用类型
CCS软件安装教程(超级详细)「建议收藏」
【每日一题】1161. 最大层内元素和
iframe tag attribute description detailed [easy to understand]
Gradle系列——Gradle测试,Gradle生命周期,settings.gradle说明,Gradle任务(基于Groovy文档4.0.4)day2-3