From de243149a98a01f8728490c2f2fb5e777f8f3af0 Mon Sep 17 00:00:00 2001 From: = <=> Date: Wed, 15 Nov 2023 14:57:40 +0800 Subject: [PATCH] =?UTF-8?q?=E6=8A=A5=E5=91=8A=E4=B8=AD=E6=B7=BB=E5=8A=A0?= =?UTF-8?q?=E6=B5=8B=E8=AF=95=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- docs/不加密、SM2+AES加密和SSL加密效率测试.MD | 27 +++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-) diff --git a/docs/不加密、SM2+AES加密和SSL加密效率测试.MD b/docs/不加密、SM2+AES加密和SSL加密效率测试.MD index 7f3dbbb0..316482e4 100644 --- a/docs/不加密、SM2+AES加密和SSL加密效率测试.MD +++ b/docs/不加密、SM2+AES加密和SSL加密效率测试.MD @@ -60,4 +60,29 @@ ## 测试结论 -从测试结果可以看出,在请求的文件大小小于50KB时,SM2+AES的方式比SSL的方式效率高,当请求的文件大小大于50KB时,SSL的方式比SM2+AES的方式效率高。 \ No newline at end of file +从测试结果可以看出,在请求的文件大小小于50KB时,SM2+AES的方式比SSL的方式效率高,当请求的文件大小大于50KB时,SSL的方式比SM2+AES的方式效率高。 + +## 测试使用的代码 +```java + public static void main(String[] args) { + int serialNumber = 1; + int[] ports = new int[]{9101, 9102, 9103}; + Map portMap = new HashMap<>(); + portMap.put(9101, "不加密"); + portMap.put(9102, "SM2+AES"); + portMap.put(9103, "SSL"); + HttpUtil.downloadBytes("http://127.0.0.1:9101/1KB"); // 使用不加密通道做一下测试,避免初始化时耗时过高 + String[] fileNames = "1KB,10KB,20KB,50KB,100KB,1MB,2MB,5MB,10MB,20MB,100MB,500MB".split(","); + for (String fileName : fileNames) { + for (int port : ports) { + String url = String.format("http://127.0.0.1:%s/%s", port, fileName); + long startTime = System.currentTimeMillis(); + HttpUtil.downloadBytes(url); + long endTime = System.currentTimeMillis(); + long resTimeMs = endTime - startTime; + String record = String.format("%s|%s|%s|%s", serialNumber++, portMap.get(port), fileName, resTimeMs); + System.out.println(record); + } + } + } +``` \ No newline at end of file