Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add HighwayFingerprint64 to ChecksumBenchmark #7507

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,23 @@ byte fingerprintChecksum(int reps) throws Exception {
return result;
}

// HighwayFingerprint64

@Benchmark
byte highwayFingerprint64HashFunction(int reps) {
return runHashFunction(reps, Hashing.highwayFingerprint64());

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This method does not exist in the Hashing class, or maybe it's not accessible due to scope or visibility issues

}

@Benchmark
byte highwayFingerprint64Checksum(int reps) throws Exception {
byte result = 0x01;
for (int i = 0; i < reps; i++) {
HashCode checksum = Hashing.highwayFingerprint64().hashBytes(testBytes, 0, testBytes.length);
result = (byte) (result ^ checksum.asLong());
}
return result;
}

// Helpers + main

private byte runHashFunction(int reps, HashFunction hashFunction) {
Expand All @@ -119,6 +136,7 @@ private byte runHashFunction(int reps, HashFunction hashFunction) {
result ^= Hashing.crc32().hashInt(reps).asBytes()[0];
result ^= Hashing.adler32().hashInt(reps).asBytes()[0];
result ^= Hashing.fingerprint2011().hashInt(reps).asBytes()[0];
result ^= Hashing.highwayFingerprint64().hashInt(reps).asBytes()[0];
for (int i = 0; i < reps; i++) {
result ^= hashFunction.hashBytes(testBytes).asBytes()[0];
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,23 @@ byte fingerprintChecksum(int reps) throws Exception {
return result;
}

// HighwayFingerprint64

@Benchmark
byte highwayFingerprint64HashFunction(int reps) {
return runHashFunction(reps, Hashing.highwayFingerprint64());
}

@Benchmark
byte highwayFingerprint64Checksum(int reps) throws Exception {
byte result = 0x01;
for (int i = 0; i < reps; i++) {
HashCode checksum = Hashing.highwayFingerprint64().hashBytes(testBytes, 0, testBytes.length);
result = (byte) (result ^ checksum.asLong());
}
return result;
}

// Helpers + main

private byte runHashFunction(int reps, HashFunction hashFunction) {
Expand All @@ -119,6 +136,7 @@ private byte runHashFunction(int reps, HashFunction hashFunction) {
result ^= Hashing.crc32().hashInt(reps).asBytes()[0];
result ^= Hashing.adler32().hashInt(reps).asBytes()[0];
result ^= Hashing.fingerprint2011().hashInt(reps).asBytes()[0];
result ^= Hashing.highwayFingerprint64().hashInt(reps).asBytes()[0];
for (int i = 0; i < reps; i++) {
result ^= hashFunction.hashBytes(testBytes).asBytes()[0];
}
Expand Down
Loading