Add benchmarks for AES and SHA-256

This commit is contained in:
str4d
2017-07-25 03:43:04 +00:00
parent 49ed17032c
commit 32968af39c
3 changed files with 151 additions and 59 deletions

View File

@ -92,63 +92,4 @@ public final class SHA256Generator {
throw new RuntimeException(e);
}
}
//private static final int RUNS = 100000;
/**
* Test the GNU and the JVM's implementations for speed
*
* Results: 2011-05 eeepc Atom
* <pre>
* JVM strlen GNU ms JVM ms
* Oracle 387 3861 3565
* Oracle 40 825 635
* Harmony 387 8082 5158
* Harmony 40 4137 1753
* JamVM 387 36301 34100
* JamVM 40 7022 6016
* gij 387 125833 4342
* gij 40 22417 988
* </pre>
*/
/****
public static void main(String args[]) {
if (args.length <= 0) {
System.err.println("Usage: SHA256Generator string");
return;
}
byte[] data = args[0].getBytes();
Sha256Standalone gnu = new Sha256Standalone();
long start = System.currentTimeMillis();
for (int i = 0; i < RUNS; i++) {
gnu.update(data, 0, data.length);
byte[] sha = gnu.digest();
if (i == 0)
System.out.println("SHA256 [" + args[0] + "] = [" + Base64.encode(sha) + "]");
gnu.reset();
}
long time = System.currentTimeMillis() - start;
System.out.println("Time for " + RUNS + " SHA-256 computations:");
System.out.println("GNU time (ms): " + time);
start = System.currentTimeMillis();
MessageDigest md;
try {
md = MessageDigest.getInstance("SHA-256");
} catch (NoSuchAlgorithmException e) {
System.err.println("Fatal: " + e);
return;
}
for (int i = 0; i < RUNS; i++) {
md.reset();
byte[] sha = md.digest(data);
if (i == 0)
System.out.println("SHA256 [" + args[0] + "] = [" + Base64.encode(sha) + "]");
}
time = System.currentTimeMillis() - start;
System.out.println("JVM time (ms): " + time);
}
****/
}