From 7d12a1af80a67267759452b960da4c2cb65fa3c6 Mon Sep 17 00:00:00 2001 From: Cheney Wong Date: Wed, 2 Jul 2025 16:29:15 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B5=8B=E8=AF=95=E9=80=9A=E8=BF=87?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/test/java/test/TestAll.java | 33 ++++++++++++++++----------------- 1 file changed, 16 insertions(+), 17 deletions(-) diff --git a/src/test/java/test/TestAll.java b/src/test/java/test/TestAll.java index 053c9da..97ee2eb 100644 --- a/src/test/java/test/TestAll.java +++ b/src/test/java/test/TestAll.java @@ -338,14 +338,14 @@ public class TestAll { System.out.println("TPS: " + String.format("%.2f", tps)); System.out.println("吞吐量: " + String.format("%.2f", throughput) + " MB/S"); double avgLatency = duration * 1.0 / totalRequest; - writeToPerformanceFile("SM4-MAC短数据", 1024, 1, numberOfThreads, totalRequest, tps, avgLatency); + writeToPerformanceFile("SM4MAC 短数据", 1024, 1, numberOfThreads, totalRequest, tps, avgLatency); } public void sm4macBatchEndes() throws InterruptedException { System.out.println("-------- SM4MAC批量数据性能测试开始 --------"); sm4macBatchEnde(1, config.getTotal(), 1024); sm4macBatchEnde(40, config.getTotal(), 1024); - System.out.println("-------- SM4MAC批量数据性能测试结束 --------\n"); + System.out.println("-------- SM4MAC 批量数据性能测试结束 --------\n"); } public void sm4macBatchEnde(int numberOfThreads, int totalRequest, int plainLen) throws InterruptedException { @@ -390,7 +390,7 @@ public class TestAll { System.out.println("TPS: " + String.format("%.2f", tps)); System.out.println("吞吐量: " + String.format("%.2f", throughput) + " MB/S"); double avgLatency = duration * 1.0 / totalRequest; - writeToPerformanceFile("SM4-MAC批量数据", 1024, 1, numberOfThreads, totalRequest, String.format("%.2f", tps) + " x 4", avgLatency); + writeToPerformanceFile("SM4MAC 批量数据", 1024, 1, numberOfThreads, totalRequest, String.format("%.2f", tps) + " x 4", avgLatency); } public void sm3ShortEndes() throws InterruptedException { @@ -441,13 +441,13 @@ public class TestAll { } public void sm4ShortMacEndes() throws InterruptedException { - System.out.println("-------- SM4短数据加密生成MAC,解密验证MAC性能测试开始 --------"); + System.out.println("-------- SM4短数据加密生成MAC,验证MAC解密性能测试开始 --------"); System.out.println("单线程"); sm4ShortMacEnde(1, config.getTotal(), 1024); System.out.println("40 线程"); sm4ShortMacEnde(40, config.getTotal(), 1024); - System.out.println("-------- SM4短数据加密生成MAC,解密验证MAC性能测试结束 --------\n"); + System.out.println("-------- SM4短数据加密生成MAC,验证MAC解密性能测试结束 --------\n"); } public void sm4ShortMacEnde(int numberOfThreads, int totalRequest, int plainLen) throws InterruptedException { @@ -523,12 +523,12 @@ public class TestAll { } public void sm4BatchMacEndes() throws InterruptedException { - System.out.println("-------- SM4批量数据加密生成MAC,解密验证MAC性能测试开始 --------"); + System.out.println("-------- SM4批量数据加密生成MAC,验证MAC解密性能测试开始 --------"); System.out.println("单线程"); sm4BatchMacEnde(1, config.getTotal(), 1024); System.out.println("40 线程"); sm4BatchMacEnde(40, config.getTotal(), 1024); - System.out.println("-------- SM4批量数据加密生成MAC,解密验证MAC性能测试结束 --------\n"); + System.out.println("-------- SM4批量数据加密生成MAC,验证MAC解密性能测试结束 --------\n"); } public void sm4BatchMacEnde(int numberOfThreads, int totalRequest, int plainLen) throws InterruptedException { @@ -610,7 +610,7 @@ public class TestAll { public void sm4LongEnde() { System.out.println("-------- SM4长数据加解密性能测试开始 --------"); - byte[] data = new byte[1024 * 4]; + byte[] data = new byte[2048]; int key = 0; // ByteBuffer enDataBuff = ByteBuffer.allocate(100 * 1024 * 1024 + 16); @@ -642,9 +642,8 @@ public class TestAll { sm4 = api.initSM4(key, ECB_DEC); for (int i = 0; i < 100 * 1024 * 1024 / data.length; i++) { - sm4.update(Arrays.copyOfRange(res, i * 1024, (i + 1) * 1024)); + sm4.update(data); } - sm4.update(Arrays.copyOfRange(res, 100 * 1024 * 1024, 100 * 1024 * 1024 + 16)); // sm4.finish(); end = System.currentTimeMillis(); @@ -662,7 +661,7 @@ public class TestAll { public void sm4MacLongEnde() { System.out.println("-------- SM4MAC长数据性能测试开始 --------"); - byte[] data = new byte[1024 * 4]; + byte[] data = new byte[2048]; SydApiBuilder builder = new SydApiBuilder( config.getIps(), @@ -694,7 +693,7 @@ public class TestAll { public void sm3LongEnde() { System.out.println("-------- SM3长数据性能测试开始 --------"); - byte[] data = new byte[1024 * 4]; + byte[] data = new byte[2048]; SydApiBuilder builder = new SydApiBuilder( config.getIps(), @@ -1276,11 +1275,11 @@ public class TestAll { System.out.println("5. SM4 短数据加解密"); System.out.println("6. SM4 批量数据加解密"); - System.out.println("7. SM4-MAC 短数据"); - System.out.println("8. SM4-MAC 批量数据"); + System.out.println("7. SM4MAC 短数据"); + System.out.println("8. SM4MAC 批量数据"); System.out.println("9. SM4短数据加密后生成MAC,解密验证MAC"); - System.out.println("10. SM4批量数据加密后生成MAC,解密验证MAC"); + System.out.println("10. SM4批量数据加密后生成MAC,验证MAC解密"); System.out.println("11. SM4长数据加解密"); @@ -1364,8 +1363,8 @@ public class TestAll { System.out.println("请选择测试项:"); System.out.println("1.SM4 短数据加解密"); System.out.println("2.SM4 批量数据加解密"); - System.out.println("3.SM4-MAC短数据"); - System.out.println("4.SM4-MAC批量数据"); + System.out.println("3.SM4MAC 短数据"); + System.out.println("4.SM4MAC 批量数据"); System.out.println("5.SM3 短数据"); System.out.println("6.SM4 短数据加密后生成MAC,解密验证MAC"); System.out.println("7.SM4 批量数据加密后生成MAC,解密验证MAC");