jmeter 测试可用

This commit is contained in:
cheney
2026-06-08 17:03:46 +08:00
parent d6a27f3341
commit b82002801d
4 changed files with 838 additions and 7 deletions
@@ -0,0 +1,103 @@
package com.sunyard.entity;
/**
* SM2加密解密时间统计类
* 用于记录发送、计算、接收三个阶段的耗时
*/
public class TimeStats {
// 发送阶段总耗时(毫秒)- 循环发送数据块的时间
private long sendTime;
// 计算阶段耗时(毫秒)- 执行加密/解密计算的时间
private long computeTime;
// 接收阶段总耗时(毫秒)- 循环接收数据块的时间
private long receiveTime;
// 发送次数
private int sendCount;
// 接收次数
private int receiveCount;
public TimeStats() {
this.sendTime = 0;
this.computeTime = 0;
this.receiveTime = 0;
this.sendCount = 0;
this.receiveCount = 0;
}
public long getSendTime() {
return sendTime;
}
public void setSendTime(long sendTime) {
this.sendTime = sendTime;
}
public long getComputeTime() {
return computeTime;
}
public void setComputeTime(long computeTime) {
this.computeTime = computeTime;
}
public long getReceiveTime() {
return receiveTime;
}
public void setReceiveTime(long receiveTime) {
this.receiveTime = receiveTime;
}
public int getSendCount() {
return sendCount;
}
public void setSendCount(int sendCount) {
this.sendCount = sendCount;
}
public int getReceiveCount() {
return receiveCount;
}
public void setReceiveCount(int receiveCount) {
this.receiveCount = receiveCount;
}
/**
* 获取总耗时
*/
public long getTotalTime() {
return sendTime + computeTime + receiveTime;
}
/**
* 获取各阶段耗时占比
*/
public double getSendPercentage() {
long total = getTotalTime();
return total == 0 ? 0 : (double) sendTime / total * 100;
}
public double getComputePercentage() {
long total = getTotalTime();
return total == 0 ? 0 : (double) computeTime / total * 100;
}
public double getReceivePercentage() {
long total = getTotalTime();
return total == 0 ? 0 : (double) receiveTime / total * 100;
}
@Override
public String toString() {
return String.format(
"TimeStats{sendTime=%dms(%.1f%%), computeTime=%dms(%.1f%%), receiveTime=%dms(%.1f%%), total=%dms, sendCount=%d, receiveCount=%d}",
sendTime, getSendPercentage(),
computeTime, getComputePercentage(),
receiveTime, getReceivePercentage(),
getTotalTime(),
sendCount, receiveCount
);
}
}