Skip to content

Commit

Permalink
removal of table for symertric ciphers and addition of mode for RSA r…
Browse files Browse the repository at this point in the history
…esults
  • Loading branch information
Jack Tjaden committed Jan 28, 2025
1 parent 1464f77 commit 7f56ca9
Showing 1 changed file with 9 additions and 15 deletions.
24 changes: 9 additions & 15 deletions examples/provider/CryptoBenchmark.java
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ private static void printDeltaTable() {
deltaPercent = ((wolfSpeed / otherSpeed) - 1.0) * 100;
}
System.out.printf("| %-40s | %-8s | %+8.2f | %+8.1f |%n",
operation,
operation.replace("RSA", "RSA/ECB/PKCS1Padding RSA"),
provider,
deltaValue,
deltaPercent);
Expand Down Expand Up @@ -223,7 +223,7 @@ private static void runEncDecBenchmark(String algorithm, String mode, String pad
encryptThroughput = (DATA_SIZE / (encryptTime / 1000000000.0)) / (1024.0 * 1024.0);

String testName = String.format("%s (%s)", cipherName, providerName);
System.out.printf("| %-40s | %8.3f | %8.3f | %8.3f |%n",
System.out.printf(" %-40s %8.3f MiB %8.3f ms %8.3f MiB/s%n",
testName + " enc", dataSizeMiB, encryptTimeMS, encryptThroughput);

results.add(new BenchmarkResult(providerName, cipherName + " enc", encryptThroughput));
Expand All @@ -240,8 +240,8 @@ private static void runEncDecBenchmark(String algorithm, String mode, String pad
decryptTimeMS = decryptTime / 1000000.0;
decryptThroughput = (DATA_SIZE / (decryptTime / 1000000000.0)) / (1024.0 * 1024.0);

System.out.printf("| %-40s | %8.3f | %8.3f | %8.3f |%n",
testName + " dec", dataSizeMiB, decryptTimeMS, decryptThroughput);
System.out.printf(" %-40s %8.3f MiB %8.3f ms %8.3f MiB/s%n",
testName + " dec", dataSizeMiB , decryptTimeMS, decryptThroughput);

/* Store decryption result */
results.add(new BenchmarkResult(providerName, cipherName + " dec", decryptThroughput));
Expand All @@ -260,15 +260,15 @@ private static void printRSAResults(int operations, double totalTime, String ope

/* Print formatted results */
System.out.printf("%-12s %-8s %8d ops took %.3f sec, avg %.3f ms, %.3f ops/sec%n",
operation,
operation + " (" + mode + ")",
" ",
operations,
totalTime,
avgTimeMs,
opsPerSec);

/* Store results for delta table */
String fullOperation = String.format("%s (%s)", operation, mode);
String fullOperation = operation; // Remove the mode from here since it's already included in the operation
results.add(new BenchmarkResult(providerName, fullOperation, opsPerSec));
}

Expand Down Expand Up @@ -383,9 +383,7 @@ public static void main(String[] args) {

System.out.println("-----------------------------------------------------------------------------");
System.out.println(" Symmetric Cipher Benchmark");
System.out.println("-----------------------------------------------------------------------------");
System.out.println("| Operation | Size MiB | ms | MiB/s |");
System.out.println("|------------------------------------------|----------|----------|----------|");
System.out.println("-----------------------------------------------------------------------------\n");

/* Run symmetric benchmarks */
for (int i = 0; i < providers.length; i++) {
Expand All @@ -399,17 +397,13 @@ public static void main(String[] args) {
runEncDecBenchmark("DESede", "CBC", "NoPadding", providerNames[i]);
}

if (i < providers.length - 1) {
System.out.println("|------------------------------------------|----------|----------|----------|");
}

Security.removeProvider(providers[i].getName());
}

System.out.println("-----------------------------------------------------------------------------");

/* Run RSA benchmarks */
System.out.println("\nRSA Benchmark Results");
System.out.println("\n-----------------------------------------------------------------------------");
System.out.println("RSA Benchmark Results");
System.out.println("-----------------------------------------------------------------------------");

for (Provider provider : providers) {
Expand Down

0 comments on commit 7f56ca9

Please sign in to comment.