title: Fast MD5 Library is not faster than Java 7 MD5?
body: <p>So I was looking for a faster way to calculate MD5 checksums and ran across the <a href="http://www.twmacinta.com/myjava/fast_md5.php" rel="noreferrer">Fast MD5 library</a> - but when I benchmark it with Java 7 on my machine it comes out slower than the Java version.</p>
  
  <p>Either I am doing something stupid (very likely) or Java 7 has implemented a better algorithm (also likely).  Here's my super simple "benchmark" - maybe I just didn't have enough coffee today...</p>
  
  <pre><code>    MD5 digest = new MD5();
      System.out.println(MD5.initNativeLibrary(true));
      byte[] buff = IOUtils.readFully(new FileInputStream(new File("blahblah.bin")), 64000000, true);
      ByteBuffer buffer = ByteBuffer.wrap(buff);
      for (int j = 0; j &lt; 100; j++) {
          start = System.currentTimeMillis();
          String md5Base64 = Utilities.getDigestBase64(buffer);
          end = System.currentTimeMillis();
          total = total + (end-start);
      }
      System.out.println("Took " + ((total)/100.00) + " ms. for " + buff.length+" bytes");
      total = 0;
      for (int i = 0; i &lt; 100; i++) {
          start = System.currentTimeMillis();
          digest.Init();
          digest.Update(buff);
          digest.Final();
          end = System.currentTimeMillis();
          total = total + (end-start);
      }
      System.out.println("Took " + ((total)/100.00) + " ms. for " + buff.length+" bytes");
  </code></pre>
  
  <p>And I get:</p>
  
  <pre><code>Took 247.99 ms. for 64000000 bytes
  Took 295.16 ms. for 64000000 bytes
  </code></pre>
  
  <p>Per a comment I ran the benchamrk over and over and got the strangest results.  The FastMD5 calculation stays the same, but the Java 7 version gets slower.  ????</p>
  
  <pre><code>Took 246.54 ms. for 64000000 bytes
  Took 294.69 ms. for 64000000 bytes
  ************************************
  Took 540.55 ms. for 64000000 bytes
  Took 292.69 ms. for 64000000 bytes
  ************************************
  Took 537.07 ms. for 64000000 bytes
  Took 292.12 ms. for 64000000 bytes
  </code></pre>
  
  <hr>