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

Gradle series - Gradle tests, Gradle life cycle, settings.gradle description, Gradle tasks (based on Groovy documentation 4.0.4) day2-3

gpio analog serial communication

论文详读《基于改进 LeNet-5 模型的手写体中文识别》,未完待补充

RGB系列开发稳定响应快速灯带拾音灯氛围灯等应用定制方案

【2022蓝帽杯】file_session && 浅入opcode

Gradle系列——Gradle测试,Gradle生命周期,settings.gradle说明,Gradle任务(基于Groovy文档4.0.4)day2-3

直播系统聊天技术(八):vivo直播系统中IM消息模块的架构实践

ThreadLocal保存用户登录信息

什么是混合元编程

HTB-Mirai
随机推荐
十九届浙大城院程序设计竞赛 F.Sum of Numerators(数学/找规律)
直播系统聊天技术(八):vivo直播系统中IM消息模块的架构实践
【每日一题】593. 有效的正方形
AtCoder Beginner Contest 261 D - Flipping and Bonus
解读selenium webdriver
树和二叉树的转换
Programmer's Romantic Tanabata
win10+Qt5.15.2 realizes low-power bluetooth control
Performance Optimization - Resource Optimization Notes
牛客刷SQL--6
阿里巴巴测试开发岗P6面试题
分布式中的远程调用
Gradle series - Gradle tests, Gradle life cycle, settings.gradle description, Gradle tasks (based on Groovy documentation 4.0.4) day2-3
全球都热炸了,谷歌服务器已经崩掉了
论文笔记All about Eve: Execute-Verify Replication for Multi-Core Servers
【每日一题】1161. 最大层内元素和
微服务原生案例搭建
2022-07-25 网工进阶(二十一)BGP-路由反射器、联盟、聚合
什么是混合元编程
[Binary Tree] Path Sum II