整理测试代码
This commit is contained in:
parent
ffae50c347
commit
fc1c22b8a3
@ -145,7 +145,7 @@ public class LongDataTest {
|
|||||||
@Test
|
@Test
|
||||||
public void case7() {
|
public void case7() {
|
||||||
byte[] data = new byte[4064];
|
byte[] data = new byte[4064];
|
||||||
ISM4 sydApiSM4 = api.initSM4(0, 0);
|
ISM4 sydApiSM4 = api.initSM4(0, 1);
|
||||||
for (int i = 0; i < 10; i++) {
|
for (int i = 0; i < 10; i++) {
|
||||||
sydApiSM4.update(data);
|
sydApiSM4.update(data);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -72,6 +72,18 @@ public class TestAll {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void writeToPerformanceFile(String interfaceName, int dataLen, int machineCount, int threadNum, int totalRequests, String tps, double avgLatency) {
|
||||||
|
try (FileWriter fw = new FileWriter(PERF_RESULT_FILE, true);
|
||||||
|
BufferedWriter bw = new BufferedWriter(fw)) {
|
||||||
|
String line = String.format("%s\t%d\t%d\t%d\t%d\t%s\t%.2f",
|
||||||
|
interfaceName, dataLen, machineCount, threadNum, totalRequests, tps, avgLatency);
|
||||||
|
bw.write(line);
|
||||||
|
bw.newLine();
|
||||||
|
} catch (IOException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private void writeToPerformanceFile2(String interfaceName, String dataLen, int machineCount, int threadNum, double totalRequests) {
|
private void writeToPerformanceFile2(String interfaceName, String dataLen, int machineCount, int threadNum, double totalRequests) {
|
||||||
try (FileWriter fw = new FileWriter(PERF_RESULT_FILE, true);
|
try (FileWriter fw = new FileWriter(PERF_RESULT_FILE, true);
|
||||||
BufferedWriter bw = new BufferedWriter(fw)) {
|
BufferedWriter bw = new BufferedWriter(fw)) {
|
||||||
@ -251,7 +263,7 @@ public class TestAll {
|
|||||||
System.out.println("TPS: " + String.format("%.2f", tps));
|
System.out.println("TPS: " + String.format("%.2f", tps));
|
||||||
System.out.println("吞吐量: " + String.format("%.2f", throughput) + " MB/S");
|
System.out.println("吞吐量: " + String.format("%.2f", throughput) + " MB/S");
|
||||||
double avgLatency = duration * 1.0 / totalRequest;
|
double avgLatency = duration * 1.0 / totalRequest;
|
||||||
writeToPerformanceFile("SM4批量数据加密", 1024, 1, numberOfThreads, totalRequest, tps, avgLatency);
|
writeToPerformanceFile("SM4批量数据加密", 1024, 1, numberOfThreads, totalRequest, String.format("%.2f", tps) + " x 4", avgLatency);
|
||||||
|
|
||||||
SydApi apiTest = Api.get();
|
SydApi apiTest = Api.get();
|
||||||
List<byte[]> res = apiTest.SYD_SM4_BatchData(keyIdx, data, ECB_ENC);
|
List<byte[]> res = apiTest.SYD_SM4_BatchData(keyIdx, data, ECB_ENC);
|
||||||
@ -378,7 +390,7 @@ public class TestAll {
|
|||||||
System.out.println("TPS: " + String.format("%.2f", tps));
|
System.out.println("TPS: " + String.format("%.2f", tps));
|
||||||
System.out.println("吞吐量: " + String.format("%.2f", throughput) + " MB/S");
|
System.out.println("吞吐量: " + String.format("%.2f", throughput) + " MB/S");
|
||||||
double avgLatency = duration * 1.0 / totalRequest;
|
double avgLatency = duration * 1.0 / totalRequest;
|
||||||
writeToPerformanceFile("SM4MAC短数据", 1024, 1, numberOfThreads, totalRequest, tps, avgLatency);
|
writeToPerformanceFile("SM4-MAC批量数据", 1024, 1, numberOfThreads, totalRequest, String.format("%.2f", tps) + " x 4", avgLatency);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void sm3ShortEndes() throws InterruptedException {
|
public void sm3ShortEndes() throws InterruptedException {
|
||||||
@ -425,7 +437,7 @@ public class TestAll {
|
|||||||
System.out.println("TPS: " + String.format("%.2f", tps));
|
System.out.println("TPS: " + String.format("%.2f", tps));
|
||||||
System.out.println("吞吐量: " + String.format("%.2f", throughput) + " MB/S");
|
System.out.println("吞吐量: " + String.format("%.2f", throughput) + " MB/S");
|
||||||
double avgLatency = duration * 1.0 / totalRequest;
|
double avgLatency = duration * 1.0 / totalRequest;
|
||||||
writeToPerformanceFile("SM3", 1024, 1, numberOfThreads, totalRequest, tps, avgLatency);
|
writeToPerformanceFile("SM3 短数据", 1024, 1, numberOfThreads, totalRequest, tps, avgLatency);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void sm4ShortMacEndes() throws InterruptedException {
|
public void sm4ShortMacEndes() throws InterruptedException {
|
||||||
@ -567,7 +579,7 @@ public class TestAll {
|
|||||||
System.out.println("TPS: " + String.format("%.2f", tps));
|
System.out.println("TPS: " + String.format("%.2f", tps));
|
||||||
System.out.println("吞吐量: " + String.format("%.2f", throughput) + " MB/S");
|
System.out.println("吞吐量: " + String.format("%.2f", throughput) + " MB/S");
|
||||||
double avgLatency = duration * 1.0 / totalRequest;
|
double avgLatency = duration * 1.0 / totalRequest;
|
||||||
writeToPerformanceFile("SM4批量数据加密并生成MAC", 1024, 1, numberOfThreads, totalRequest, tps, avgLatency);
|
writeToPerformanceFile("SM4批量数据加密并生成MAC", 1024, 1, numberOfThreads, totalRequest, String.format("%.2f", tps) + " x 4", avgLatency);
|
||||||
|
|
||||||
ExecutorService poolDec = Executors.newFixedThreadPool(numberOfThreads);
|
ExecutorService poolDec = Executors.newFixedThreadPool(numberOfThreads);
|
||||||
start = System.currentTimeMillis();
|
start = System.currentTimeMillis();
|
||||||
@ -590,7 +602,7 @@ public class TestAll {
|
|||||||
System.out.println("TPS: " + String.format("%.2f", tps));
|
System.out.println("TPS: " + String.format("%.2f", tps));
|
||||||
System.out.println("吞吐量: " + String.format("%.2f", throughput) + " MB/S");
|
System.out.println("吞吐量: " + String.format("%.2f", throughput) + " MB/S");
|
||||||
avgLatency = duration * 1.0 / totalRequest;
|
avgLatency = duration * 1.0 / totalRequest;
|
||||||
writeToPerformanceFile("SM4批量数据解密并校验MAC", 1024, 1, numberOfThreads, totalRequest, tps, avgLatency);
|
writeToPerformanceFile("SM4批量数据解密并校验MAC", 1024, 1, numberOfThreads, totalRequest, String.format("%.2f", tps) + " x 4", avgLatency);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -600,7 +612,7 @@ public class TestAll {
|
|||||||
|
|
||||||
byte[] data = new byte[1024 * 4];
|
byte[] data = new byte[1024 * 4];
|
||||||
int key = 0;
|
int key = 0;
|
||||||
ByteBuffer enDataBuff = ByteBuffer.allocate(100 * 1024 * 1024 + 16);
|
// ByteBuffer enDataBuff = ByteBuffer.allocate(100 * 1024 * 1024 + 16);
|
||||||
|
|
||||||
SydApiBuilder builder = new SydApiBuilder(
|
SydApiBuilder builder = new SydApiBuilder(
|
||||||
config.getIps(),
|
config.getIps(),
|
||||||
@ -633,7 +645,7 @@ public class TestAll {
|
|||||||
sm4.update(Arrays.copyOfRange(res, i * 1024, (i + 1) * 1024));
|
sm4.update(Arrays.copyOfRange(res, i * 1024, (i + 1) * 1024));
|
||||||
}
|
}
|
||||||
sm4.update(Arrays.copyOfRange(res, 100 * 1024 * 1024, 100 * 1024 * 1024 + 16));
|
sm4.update(Arrays.copyOfRange(res, 100 * 1024 * 1024, 100 * 1024 * 1024 + 16));
|
||||||
sm4.finish();
|
// sm4.finish();
|
||||||
|
|
||||||
end = System.currentTimeMillis();
|
end = System.currentTimeMillis();
|
||||||
duration = end - start;
|
duration = end - start;
|
||||||
@ -650,7 +662,7 @@ public class TestAll {
|
|||||||
public void sm4MacLongEnde() {
|
public void sm4MacLongEnde() {
|
||||||
System.out.println("-------- SM4MAC长数据性能测试开始 --------");
|
System.out.println("-------- SM4MAC长数据性能测试开始 --------");
|
||||||
|
|
||||||
byte[] data = new byte[1024];
|
byte[] data = new byte[1024 * 4];
|
||||||
|
|
||||||
SydApiBuilder builder = new SydApiBuilder(
|
SydApiBuilder builder = new SydApiBuilder(
|
||||||
config.getIps(),
|
config.getIps(),
|
||||||
@ -682,7 +694,7 @@ public class TestAll {
|
|||||||
public void sm3LongEnde() {
|
public void sm3LongEnde() {
|
||||||
System.out.println("-------- SM3长数据性能测试开始 --------");
|
System.out.println("-------- SM3长数据性能测试开始 --------");
|
||||||
|
|
||||||
byte[] data = new byte[1024];
|
byte[] data = new byte[1024 * 4];
|
||||||
|
|
||||||
SydApiBuilder builder = new SydApiBuilder(
|
SydApiBuilder builder = new SydApiBuilder(
|
||||||
config.getIps(),
|
config.getIps(),
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user