-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #322 from dynatrace-oss/xxh3-128
Xxh3 128
- Loading branch information
Showing
47 changed files
with
2,201 additions
and
953 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
51 changes: 51 additions & 0 deletions
51
src/jmh/java/com/dynatrace/hash4j/hashing/AbstactHasher128PerformanceTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
/* | ||
* Copyright 2022-2025 Dynatrace LLC | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package com.dynatrace.hash4j.hashing; | ||
|
||
import org.openjdk.jmh.infra.Blackhole; | ||
|
||
public abstract class AbstactHasher128PerformanceTest extends AbstractPerformanceTest { | ||
|
||
protected static final HashFunnel<CharSequence> CHARS_FUNNEL = (s, sink) -> sink.putChars(s); | ||
protected static final HashFunnel<byte[]> BYTES_FUNNEL = (s, sink) -> sink.putBytes(s); | ||
|
||
@Override | ||
protected void hashObject(TestObject testObject, Blackhole blackhole) { | ||
blackhole.consume(getHasherInstance().hashTo128Bits(testObject, TestObject::contributeToHash)); | ||
} | ||
|
||
@Override | ||
protected void hashBytesDirect(byte[] b, Blackhole blackhole) { | ||
blackhole.consume(getHasherInstance().hashBytesTo128Bits(b)); | ||
} | ||
|
||
@Override | ||
protected void hashBytesIndirect(byte[] b, Blackhole blackhole) { | ||
blackhole.consume(getHasherInstance().hashTo128Bits(b, BYTES_FUNNEL)); | ||
} | ||
|
||
@Override | ||
protected void hashCharsDirect(String s, Blackhole blackhole) { | ||
blackhole.consume(getHasherInstance().hashCharsTo128Bits(s)); | ||
} | ||
|
||
@Override | ||
protected void hashCharsIndirect(String s, Blackhole blackhole) { | ||
blackhole.consume(getHasherInstance().hashTo128Bits(s, CHARS_FUNNEL)); | ||
} | ||
|
||
protected abstract Hasher128 getHasherInstance(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
53 changes: 53 additions & 0 deletions
53
src/jmh/java/com/dynatrace/hash4j/hashing/AbstractGuava128BitPerformanceTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
/* | ||
* Copyright 2022-2025 Dynatrace LLC | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package com.dynatrace.hash4j.hashing; | ||
|
||
import com.google.common.hash.Funnel; | ||
import com.google.common.hash.HashFunction; | ||
import org.openjdk.jmh.infra.Blackhole; | ||
|
||
public abstract class AbstractGuava128BitPerformanceTest extends AbstractPerformanceTest { | ||
|
||
protected static final Funnel<String> CHARS_FUNNEL = (s, sink) -> sink.putUnencodedChars(s); | ||
protected static final Funnel<byte[]> BYTES_FUNNEL = (s, sink) -> sink.putBytes(s); | ||
|
||
@Override | ||
protected void hashObject(TestObject testObject, Blackhole blackhole) { | ||
blackhole.consume(createHashFunction().hashObject(testObject, TestObject::contributeToHash)); | ||
} | ||
|
||
@Override | ||
protected void hashBytesDirect(byte[] b, Blackhole blackhole) { | ||
blackhole.consume(createHashFunction().hashBytes(b)); | ||
} | ||
|
||
@Override | ||
protected void hashCharsDirect(String s, Blackhole blackhole) { | ||
blackhole.consume(createHashFunction().hashUnencodedChars(s)); | ||
} | ||
|
||
@Override | ||
protected void hashCharsIndirect(String s, Blackhole blackhole) { | ||
blackhole.consume(createHashFunction().hashObject(s, CHARS_FUNNEL)); | ||
} | ||
|
||
@Override | ||
protected void hashBytesIndirect(byte[] b, Blackhole blackhole) { | ||
blackhole.consume(createHashFunction().hashObject(b, BYTES_FUNNEL)); | ||
} | ||
|
||
protected abstract HashFunction createHashFunction(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.