@Test public void testPerformance() { long time = System.currentTimeMillis(); int total = 10000000; for (int i = 0; i < total; i++) { FastUUID.get(); } System.out.println(System.currentTimeMillis() - time); time = System.currentTimeMillis(); for (int i = 0; i < total; i++) { RandomGuid.getRandomGuid(false); } System.out.println(System.currentTimeMillis() - time); }
public static String getRandomGuid(final boolean secure) { MessageDigest md5 = null; StringBuilder sbValueBeforeMD5 = new StringBuilder(32); try { md5 = MessageDigest.getInstance("MD5"); } catch (final NoSuchAlgorithmException e) { throw new RuntimeException(e); } long rand; if (secure) { rand = secureRandom.nextLong(); } else { rand = random.nextLong(); } sbValueBeforeMD5.append(id).append(System.currentTimeMillis()).append(':').append(rand); md5.update(sbValueBeforeMD5.toString().getBytes()); return getHexString(md5.digest()); }
RandomGuid { public static String getRandomGuid(final boolean secure) { MessageDigest md5 = null; StringBuilder sbValueBeforeMD5 = new StringBuilder(32); try { md5 = MessageDigest.getInstance("MD5"); } catch (final NoSuchAlgorithmException e) { throw new RuntimeException(e); } long rand; if (secure) { rand = secureRandom.nextLong(); } else { rand = random.nextLong(); } sbValueBeforeMD5.append(id).append(System.currentTimeMillis()).append(':').append(rand); md5.update(sbValueBeforeMD5.toString().getBytes()); return getHexString(md5.digest()); } }
RandomGuid { public static String getRandomGuid(final boolean secure) { MessageDigest md5 = null; StringBuilder sbValueBeforeMD5 = new StringBuilder(32); try { md5 = MessageDigest.getInstance("MD5"); } catch (final NoSuchAlgorithmException e) { throw new RuntimeException(e); } long rand; if (secure) { rand = secureRandom.nextLong(); } else { rand = random.nextLong(); } sbValueBeforeMD5.append(id).append(System.currentTimeMillis()).append(':').append(rand); md5.update(sbValueBeforeMD5.toString().getBytes()); return getHexString(md5.digest()); } private  RandomGuid(); }
RandomGuid { public static String getRandomGuid(final boolean secure) { MessageDigest md5 = null; StringBuilder sbValueBeforeMD5 = new StringBuilder(32); try { md5 = MessageDigest.getInstance("MD5"); } catch (final NoSuchAlgorithmException e) { throw new RuntimeException(e); } long rand; if (secure) { rand = secureRandom.nextLong(); } else { rand = random.nextLong(); } sbValueBeforeMD5.append(id).append(System.currentTimeMillis()).append(':').append(rand); md5.update(sbValueBeforeMD5.toString().getBytes()); return getHexString(md5.digest()); } private  RandomGuid(); static String getRandomGuid(final boolean secure); }
RandomGuid { public static String getRandomGuid(final boolean secure) { MessageDigest md5 = null; StringBuilder sbValueBeforeMD5 = new StringBuilder(32); try { md5 = MessageDigest.getInstance("MD5"); } catch (final NoSuchAlgorithmException e) { throw new RuntimeException(e); } long rand; if (secure) { rand = secureRandom.nextLong(); } else { rand = random.nextLong(); } sbValueBeforeMD5.append(id).append(System.currentTimeMillis()).append(':').append(rand); md5.update(sbValueBeforeMD5.toString().getBytes()); return getHexString(md5.digest()); } private  RandomGuid(); static String getRandomGuid(final boolean secure);  }