当前位置:网站首页>动态模型中嵌入静态模型实践
动态模型中嵌入静态模型实践
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自动化专题
- 测试工具专题
阅读原文,跳转我的仓库地址边栏推荐
猜你喜欢

透过开发抽奖小程序,体会创新与迭代

A Beginner's Guide to Performance Testing

fh511小风扇主控芯片 便携式小风扇专用8脚IC 三档小风扇升压芯片sop8

AD单片机九齐单片机NY8B062D SOP16九齐

荣信文化通过注册:年营收3.8亿 王艺桦夫妇为实控人

Wovent Bio IPO: Annual revenue of 480 million pension fund is a shareholder

开放原子全球开源峰会原圆满结束,openEuler模式得到参会者高度认可

透过现象看本质,如何针对用户做好需求分析

Longkou united chemical registration: through 550 million revenue xiu-mei li control 92.5% stake

【每日一题】1331. 数组序号转换
随机推荐
大佬们,datax同步数据,同步过程中要新增一个uuid,请问column 怎么写pgsql,uu
kubernetes之DaemonSet以及滚动更新
datetime64[ns]转化为datetime
解读selenium webdriver
拥抱NFV,Istio 1.1 将支持多网络平面
Gradle series - Gradle tests, Gradle life cycle, settings.gradle description, Gradle tasks (based on Groovy documentation 4.0.4) day2-3
openEuler 社区12位开发者荣获年度开源贡献之星
立新能源深交所上市:市值55亿 哈密国投与国有基金是股东
[机缘参悟-57]:《素书》-4-修身养志[本德宗道章第四]
什么是闭包?
The default database main key, foreign key, and the only key index
Programmer's Romantic Tanabata
Qt实战案例(56)——利用QProcess实现应用程序重启功能
Pytorch —— 分布式模型训练
HTB-Mirai
Longkou united chemical registration: through 550 million revenue xiu-mei li control 92.5% stake
Gradle系列——Gradle测试,Gradle生命周期,settings.gradle说明,Gradle任务(基于Groovy文档4.0.4)day2-3
MBI5020 LED驱动
分布式中的远程调用
The problem that the column becomes indexed after pd groupby and the aggregation column has no column name