You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@ratis.apache.org by "133tosakarin (via GitHub)" <gi...@apache.org> on 2024/09/10 06:10:48 UTC

Re: [PR] RATIS-2147. Md5 mismatch when snapshot install [ratis]

133tosakarin commented on PR #1142:
URL: https://github.com/apache/ratis/pull/1142#issuecomment-2339746397

   private String randomString(int length) {
           StringBuilder sb = new StringBuilder();
           for (int i = 0; i < length; i++) {
               sb.append((char) (Math.random() * 26 + 'a'));
           }
           return sb.toString();
       }
   
       @Benchmark
       public void md5Test(Blackhole blackhole) throws NoSuchAlgorithmException {
           int length = 1000;
           md5 = MessageDigest.getInstance("MD5");
           for (int i = 0; i < 1000; ++i) {
               md5.reset();
               md5.update(randomString(length).getBytes());
               blackhole.consume(md5.digest());
               length += 100;
           }
       }
   
       @Benchmark
       public void md5Test2(Blackhole blackhole) throws NoSuchAlgorithmException {
           int length = 10000;
           for (int i = 0; i < 1000; ++i) {
               MessageDigest md5 = MessageDigest.getInstance("MD5");
               md5.reset();
               md5.update(randomString(length).getBytes());
               blackhole.consume(md5.digest());
               length += 100;
           }
   
       }
   
       @Benchmark
       public void md5DoNothingTest() throws NoSuchAlgorithmException {
           MessageDigest md5 = MessageDigest.getInstance("MD5");
           for (int i = 0; i < 1000000; ++i) {
               md5.reset();
           }
       }
   
       @Benchmark
       public void md5DoNothingTest2() throws NoSuchAlgorithmException {
           for (int i = 0; i < 1000000; ++i) {
               MessageDigest md5 = MessageDigest.getInstance("MD5");
               md5.reset();
           }
       }


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@ratis.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org