jmeter 测试可用
This commit is contained in:
@@ -2,6 +2,7 @@ package cmbpoc;
|
||||
|
||||
import com.sunyard.RetWrap;
|
||||
import com.sunyard.SydApi;
|
||||
import com.sunyard.entity.TimeStats;
|
||||
import com.sunyard.proto.Util;
|
||||
import org.junit.*;
|
||||
import racal.sunyard.main.SydApi4j;
|
||||
@@ -136,4 +137,48 @@ public class PerformanceTest {
|
||||
System.out.printf("Decrypt Throughput: %.2f KB/s%n", decryptThroughput);
|
||||
System.out.println();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void SYD_SM2_Encrypt_TimeStats_2M() {
|
||||
System.out.println("=== SYD_SM2_Encrypt Time Statistics Test - 2M Data ===");
|
||||
|
||||
// 预热
|
||||
for (int i = 0; i < 2; i++) {
|
||||
byte[] enData = this.api.SYD_SM2Encrypt(publicKey4Ende, orgData2M);
|
||||
byte[] deData = this.api.SYD_SM2Decrypt(privateKey4Ende, enData);
|
||||
}
|
||||
|
||||
// 正式测试
|
||||
TimeStats encryptStats = new TimeStats();
|
||||
TimeStats decryptStats = new TimeStats();
|
||||
|
||||
byte[] enData = this.api.SYD_SM2Encrypt(publicKey4Ende, orgData2M, encryptStats);
|
||||
byte[] deData = this.api.SYD_SM2Decrypt(privateKey4Ende, enData, decryptStats);
|
||||
|
||||
Assert.assertArrayEquals(orgData2M, deData);
|
||||
|
||||
System.out.println("\n--- 加密阶段时间统计 ---");
|
||||
System.out.printf("发送阶段: %d ms (%.1f%%), 发送次数: %d%n",
|
||||
encryptStats.getSendTime(), encryptStats.getSendPercentage(), encryptStats.getSendCount());
|
||||
System.out.printf("计算阶段: %d ms (%.1f%%)%n",
|
||||
encryptStats.getComputeTime(), encryptStats.getComputePercentage());
|
||||
System.out.printf("接收阶段: %d ms (%.1f%%), 接收次数: %d%n",
|
||||
encryptStats.getReceiveTime(), encryptStats.getReceivePercentage(), encryptStats.getReceiveCount());
|
||||
System.out.printf("加密总耗时: %d ms%n", encryptStats.getTotalTime());
|
||||
|
||||
System.out.println("\n--- 解密阶段时间统计 ---");
|
||||
System.out.printf("发送阶段: %d ms (%.1f%%), 发送次数: %d%n",
|
||||
decryptStats.getSendTime(), decryptStats.getSendPercentage(), decryptStats.getSendCount());
|
||||
System.out.printf("计算阶段: %d ms (%.1f%%)%n",
|
||||
decryptStats.getComputeTime(), decryptStats.getComputePercentage());
|
||||
System.out.printf("接收阶段: %d ms (%.1f%%), 接收次数: %d%n",
|
||||
decryptStats.getReceiveTime(), decryptStats.getReceivePercentage(), decryptStats.getReceiveCount());
|
||||
System.out.printf("解密总耗时: %d ms%n", decryptStats.getTotalTime());
|
||||
|
||||
System.out.println("\n--- 汇总 ---");
|
||||
long totalTime = encryptStats.getTotalTime() + decryptStats.getTotalTime();
|
||||
System.out.printf("加密解密总耗时: %d ms%n", totalTime);
|
||||
System.out.printf("加密吞吐量: %.2f KB/s%n", (2048.0 / encryptStats.getTotalTime()) * 1000);
|
||||
System.out.printf("解密吞吐量: %.2f KB/s%n", (2048.0 / decryptStats.getTotalTime()) * 1000);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user