Changeset 32968af
- Timestamp:
- Jul 25, 2017 3:43:04 AM (4 years ago)
- Branches:
- master
- Children:
- f9b8a5ec
- Parents:
- 49ed170
- Files:
-
- 2 added
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
core/java/src/net/i2p/crypto/SHA256Generator.java
r49ed170 r32968af 93 93 } 94 94 } 95 96 //private static final int RUNS = 100000;97 98 /**99 * Test the GNU and the JVM's implementations for speed100 *101 * Results: 2011-05 eeepc Atom102 * <pre>103 * JVM strlen GNU ms JVM ms104 * Oracle 387 3861 3565105 * Oracle 40 825 635106 * Harmony 387 8082 5158107 * Harmony 40 4137 1753108 * JamVM 387 36301 34100109 * JamVM 40 7022 6016110 * gij 387 125833 4342111 * gij 40 22417 988112 * </pre>113 */114 /****115 public static void main(String args[]) {116 if (args.length <= 0) {117 System.err.println("Usage: SHA256Generator string");118 return;119 }120 121 byte[] data = args[0].getBytes();122 Sha256Standalone gnu = new Sha256Standalone();123 long start = System.currentTimeMillis();124 for (int i = 0; i < RUNS; i++) {125 gnu.update(data, 0, data.length);126 byte[] sha = gnu.digest();127 if (i == 0)128 System.out.println("SHA256 [" + args[0] + "] = [" + Base64.encode(sha) + "]");129 gnu.reset();130 }131 long time = System.currentTimeMillis() - start;132 System.out.println("Time for " + RUNS + " SHA-256 computations:");133 System.out.println("GNU time (ms): " + time);134 135 start = System.currentTimeMillis();136 MessageDigest md;137 try {138 md = MessageDigest.getInstance("SHA-256");139 } catch (NoSuchAlgorithmException e) {140 System.err.println("Fatal: " + e);141 return;142 }143 for (int i = 0; i < RUNS; i++) {144 md.reset();145 byte[] sha = md.digest(data);146 if (i == 0)147 System.out.println("SHA256 [" + args[0] + "] = [" + Base64.encode(sha) + "]");148 }149 time = System.currentTimeMillis() - start;150 151 System.out.println("JVM time (ms): " + time);152 }153 ****/154 95 }
Note: See TracChangeset
for help on using the changeset viewer.