Comment fixes

pull/116/head
Jack Tjaden 2025-06-10 14:57:54 -06:00
parent b646ddb40c
commit 64fe35343a
1 changed files with 13 additions and 18 deletions

View File

@ -73,7 +73,7 @@ public class CryptoBenchmark {
int ops = 0; int ops = 0;
long startTime = System.nanoTime(); long startTime = System.nanoTime();
long elapsedTimeNano = 0; long elapsedTimeNano = 0;
long minTimeNano = TEST_MIN_TIME_SECONDS * 1_000_000_000L; // Convert seconds to nanoseconds long minTimeNano = TEST_MIN_TIME_SECONDS * 1_000_000_000L;
do { do {
operation.run(); operation.run();
@ -81,7 +81,7 @@ public class CryptoBenchmark {
elapsedTimeNano = System.nanoTime() - startTime; elapsedTimeNano = System.nanoTime() - startTime;
} while (elapsedTimeNano < minTimeNano); } while (elapsedTimeNano < minTimeNano);
double elapsedTime = elapsedTimeNano / 1_000_000_000.0; // Convert nanoseconds to seconds double elapsedTime = elapsedTimeNano / 1_000_000_000.0;
return new TimingResult(ops, elapsedTime); return new TimingResult(ops, elapsedTime);
} }
@ -356,14 +356,12 @@ public class CryptoBenchmark {
/* Sort operations by category and name for better grouping */ /* Sort operations by category and name for better grouping */
List<String> sortedOperations = new ArrayList<>(groupedResults.keySet()); List<String> sortedOperations = new ArrayList<>(groupedResults.keySet());
Collections.sort(sortedOperations, (a, b) -> { Collections.sort(sortedOperations, (a, b) -> {
// Group by algorithm type first
String categoryA = getOperationCategory(a); String categoryA = getOperationCategory(a);
String categoryB = getOperationCategory(b); String categoryB = getOperationCategory(b);
int catCompare = categoryA.compareTo(categoryB); int catCompare = categoryA.compareTo(categoryB);
if (catCompare != 0) return catCompare; if (catCompare != 0) return catCompare;
// Then sort by full operation name
return a.compareTo(b); return a.compareTo(b);
}); });
@ -374,7 +372,6 @@ public class CryptoBenchmark {
providerResults = groupedResults.get(operation); providerResults = groupedResults.get(operation);
wolfSpeed = providerResults.getOrDefault("wolfJCE", 0.0); wolfSpeed = providerResults.getOrDefault("wolfJCE", 0.0);
// Skip if wolfJCE doesn't have this operation
if (wolfSpeed == 0.0) continue; if (wolfSpeed == 0.0) continue;
for (Map.Entry<String, Double> providerEntry : providerResults.entrySet()) { for (Map.Entry<String, Double> providerEntry : providerResults.entrySet()) {
@ -423,12 +420,10 @@ public class CryptoBenchmark {
/* Helper method to format operation names nicely */ /* Helper method to format operation names nicely */
private static String formatOperationName(String operation) { private static String formatOperationName(String operation) {
// Remove any duplicate algorithm names in RSA operations
if (operation.startsWith("RSA")) { if (operation.startsWith("RSA")) {
return operation.replace(" (RSA/ECB/PKCS1Padding)", ""); return operation.replace(" (RSA/ECB/PKCS1Padding)", "");
} }
// Handle specific formatting for common operations
if (operation.contains("ECDH") || operation.contains("DH ")) { if (operation.contains("ECDH") || operation.contains("DH ")) {
return operation; return operation;
} }