Skip to content

Commit

Permalink
Changed table unit to %
Browse files Browse the repository at this point in the history
  • Loading branch information
Jack Tjaden committed Jan 10, 2025
1 parent 0ad0fbd commit 0dc8841
Showing 1 changed file with 45 additions and 46 deletions.
91 changes: 45 additions & 46 deletions examples/provider/CryptoBenchmark.java
Original file line number Diff line number Diff line change
Expand Up @@ -70,51 +70,52 @@ private static void printProviderInfo(Provider provider) {
}

private static void printDeltaTable() {
/* Variables for table generation */
Map<String, Map<String, Double>> groupedResults;
String operation;
Map<String, Double> providerResults;
double wolfSpeed;
String provider;
double otherSpeed;
double deltaMiBs;
double deltaPercent;

System.out.println("\nPerformance Delta (compared to wolfJCE)");
System.out.println("-----------------------------------------------------------------------------");
System.out.println("| Operation | Size MiB | ms | MiB/s |");
System.out.println("|------------------------------------------|----------|----------|----------|");

/* Group results by operation */
groupedResults = new HashMap<>();
for (BenchmarkResult result : results) {
groupedResults
.computeIfAbsent(result.operation, k -> new HashMap<>())
.put(result.provider, result.throughput);
/* Variables for table generation */
Map<String, Map<String, Double>> groupedResults;
String operation;
Map<String, Double> providerResults;
double wolfSpeed;
String provider;
double otherSpeed;
double deltaMiBs;
double deltaPercent;

System.out.println("\nPerformance Delta (compared to wolfJCE)");
System.out.println("-----------------------------------------------------------------------------");
System.out.println("| Operation | Provider | Delta | Delta |");
System.out.println("| | | (MiB/s) | (%) |");
System.out.println("|------------------------------------------|----------|----------|----------|");

/* Group results by operation */
groupedResults = new HashMap<>();
for (BenchmarkResult result : results) {
groupedResults
.computeIfAbsent(result.operation, k -> new HashMap<>())
.put(result.provider, result.throughput);
}

/* Calculate and print deltas */
for (Map.Entry<String, Map<String, Double>> entry : groupedResults.entrySet()) {
operation = entry.getKey();
providerResults = entry.getValue();
wolfSpeed = providerResults.getOrDefault("wolfJCE", 0.0);

for (Map.Entry<String, Double> providerEntry : providerResults.entrySet()) {
provider = providerEntry.getKey();
if (!provider.equals("wolfJCE")) {
otherSpeed = providerEntry.getValue();
deltaMiBs = wolfSpeed - otherSpeed;
deltaPercent = ((wolfSpeed / otherSpeed) - 1.0) * 100;

System.out.printf("| %-40s | %-8s | %+8.2f | %+8.1f |%n",
operation,
provider,
deltaMiBs,
deltaPercent);
}
}

/* Calculate and print deltas */
for (Map.Entry<String, Map<String, Double>> entry : groupedResults.entrySet()) {
operation = entry.getKey();
providerResults = entry.getValue();
wolfSpeed = providerResults.getOrDefault("wolfJCE", 0.0);

for (Map.Entry<String, Double> providerEntry : providerResults.entrySet()) {
provider = providerEntry.getKey();
if (!provider.equals("wolfJCE")) {
otherSpeed = providerEntry.getValue();
deltaMiBs = wolfSpeed - otherSpeed;
deltaPercent = ((wolfSpeed / otherSpeed) - 1.0) * 100;

System.out.printf("| %-40s | %-8s | %+8.2f | %+8.1f |%n",
operation,
provider,
deltaMiBs,
deltaPercent);
}
}
}
System.out.println("-----------------------------------------------------------------------------");
}
System.out.println("-----------------------------------------------------------------------------");
}

private static void runBenchmark(String algorithm, String mode, String padding,
Expand Down Expand Up @@ -253,8 +254,6 @@ public static void main(String[] args) {
providerNameList.add("BC");
}

System.out.println("DES3 Enabled: " + FeatureDetect.Des3Enabled());

Provider[] providers = providerList.toArray(new Provider[0]);
String[] providerNames = providerNameList.toArray(new String[0]);

Expand Down

0 comments on commit 0dc8841

Please sign in to comment.