add adler to checksum tests

This commit is contained in:
kimchy 2011-03-29 18:17:09 +02:00
parent 3138269573
commit a1be2bbf20
1 changed files with 14 additions and 0 deletions

View File

@ -24,6 +24,7 @@ import org.elasticsearch.common.unit.ByteSizeValue;
import org.elasticsearch.common.unit.TimeValue;
import java.security.MessageDigest;
import java.util.zip.Adler32;
import java.util.zip.CRC32;
/**
@ -36,6 +37,7 @@ public class ChecksumBenchmarkTest {
public static void main(String[] args) {
long dataSize = ByteSizeValue.parseBytesSizeValue("1g", null).bytes();
crc(dataSize);
adler(dataSize);
md5(dataSize);
}
@ -51,6 +53,18 @@ public class ChecksumBenchmarkTest {
System.out.println("CRC took " + new TimeValue(System.currentTimeMillis() - start));
}
private static void adler(long dataSize) {
long start = System.currentTimeMillis();
Adler32 crc = new Adler32();
byte[] data = new byte[BATCH_SIZE];
long iter = dataSize / BATCH_SIZE;
for (long i = 0; i < iter; i++) {
crc.update(data);
}
crc.getValue();
System.out.println("Adler took " + new TimeValue(System.currentTimeMillis() - start));
}
private static void md5(long dataSize) {
long start = System.currentTimeMillis();
byte[] data = new byte[BATCH_SIZE];