Skip to content

Commit

Permalink
Merge pull request #267 from dynatrace-oss/refactor-unit-tests
Browse files Browse the repository at this point in the history
refactored unit tests
  • Loading branch information
oertl authored Jul 30, 2024
2 parents 46e5e17 + 5b2bb73 commit ca58082
Show file tree
Hide file tree
Showing 90 changed files with 55,103 additions and 185,694 deletions.
3 changes: 2 additions & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,8 @@ dependencies {
testImplementation group: 'net.openhft', name: 'zero-allocation-hashing', version: '0.26ea0'
testImplementation group: 'com.appmattus.crypto', name: 'cryptohash', version: '1.0.2'
testImplementation group: 'org.greenrobot', name: 'essentials', version: '3.1.0'
errorprone("com.google.errorprone:error_prone_core:2.29.2")
testImplementation group: 'com.sangupta', name: 'murmur', version: '1.0.0'
errorprone('com.google.errorprone:error_prone_core:2.29.2')
}

multiRelease {
Expand Down
1,025 changes: 0 additions & 1,025 deletions reference-implementations/FarmHash NA.txt

This file was deleted.

1,025 changes: 0 additions & 1,025 deletions reference-implementations/FarmHash UO.txt

This file was deleted.

1,025 changes: 0 additions & 1,025 deletions reference-implementations/Komihash 4.3.txt

This file was deleted.

1,025 changes: 0 additions & 1,025 deletions reference-implementations/Komihash 4.5.txt

This file was deleted.

1,025 changes: 0 additions & 1,025 deletions reference-implementations/Komihash 4.7.txt

This file was deleted.

1,025 changes: 0 additions & 1,025 deletions reference-implementations/Komihash 5.0.txt

This file was deleted.

1,025 changes: 0 additions & 1,025 deletions reference-implementations/Komihash 5.10.txt

This file was deleted.

1,025 changes: 0 additions & 1,025 deletions reference-implementations/Murmur3 128.txt

This file was deleted.

1,025 changes: 0 additions & 1,025 deletions reference-implementations/Murmur3 32.txt

This file was deleted.

1,025 changes: 0 additions & 1,025 deletions reference-implementations/PolymurHash 2.0.txt

This file was deleted.

1,025 changes: 0 additions & 1,025 deletions reference-implementations/Wyhash final 3.txt

This file was deleted.

1,025 changes: 0 additions & 1,025 deletions reference-implementations/Wyhash final 4.txt

This file was deleted.

1,025 changes: 0 additions & 1,025 deletions reference-implementations/XXH3.txt

This file was deleted.

43 changes: 33 additions & 10 deletions reference-implementations/calculate_checksums.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,16 +44,37 @@ uint64_t splitmix_v1_update(uint64_t &state) {
}

template<typename T>
void computeAndPrintChecksum(const T &hashFunctionConfig = T()) {
void computeAndPrintChecksum(
const uint64_t maxSupportedLength = std::numeric_limits < uint64_t
> ::max(), const T &hashFunctionConfig = T()) {

mt19937_64 rng(0);

uint64_t maxDataLength = 1024;
uint64_t numCycles = 1000;
ofstream outputFile(
"../src/test/resources/" + hashFunctionConfig.getName() + ".txt");

ofstream outputFile(hashFunctionConfig.getName() + ".txt");
std::vector<std::pair<uint64_t, uint64_t>> lengthAndCycles;
lengthAndCycles.emplace_back(0, 1);
for (uint64_t dataLength = 1; dataLength <= 1024; ++dataLength) {
lengthAndCycles.emplace_back(dataLength, 100);
}
for (uint64_t dataLength = 1025; dataLength <= 4096; ++dataLength) {
lengthAndCycles.emplace_back(dataLength, 10);
}
lengthAndCycles.emplace_back((UINT64_C(1) << 31) - 1, 1);
lengthAndCycles.emplace_back((UINT64_C(1) << 31) + 0, 1);
lengthAndCycles.emplace_back((UINT64_C(1) << 31) + 1, 1);
lengthAndCycles.emplace_back((UINT64_C(1) << 32) - 1, 1);
lengthAndCycles.emplace_back((UINT64_C(1) << 32) + 0, 1);
lengthAndCycles.emplace_back((UINT64_C(1) << 32) + 1, 1);

for (const auto &lengthAndCycle : lengthAndCycles) {

for (uint64_t dataLength = 0; dataLength <= maxDataLength; ++dataLength) {
uint64_t dataLength = lengthAndCycle.first;
uint64_t numCycles = lengthAndCycle.second;

if (dataLength > maxSupportedLength)
continue;

uint8_t checkSum[SHA256_DIGEST_LENGTH];
SHA256_CTX sha256;
Expand All @@ -73,12 +94,12 @@ void computeAndPrintChecksum(const T &hashFunctionConfig = T()) {
std::vector < uint64_t > dataBytesTemp(effectiveDataLength);

for (uint64_t cycle = 0; cycle < numCycles; ++cycle) {
for (uint64_t i = 0; i < effectiveDataLength; ++i) {
dataBytesTemp[i] = splitmix_v1_update(rngState);
}
for (uint64_t i = 0; i < effectiveSeedLength; ++i) {
seedBytesTemp[i] = splitmix_v1_update(rngState);
}
for (uint64_t i = 0; i < effectiveDataLength; ++i) {
dataBytesTemp[i] = splitmix_v1_update(rngState);
}

uint8_t *dataBytes = reinterpret_cast<uint8_t*>(&dataBytesTemp[0]);
uint8_t *seedBytes = reinterpret_cast<uint8_t*>(&seedBytesTemp[0]);
Expand Down Expand Up @@ -113,8 +134,10 @@ int main(int argc, char *argv[]) {
computeAndPrintChecksum<Komihash5_10ChecksumConfig>();
computeAndPrintChecksum<WyhashFinal3ChecksumConfig>();
computeAndPrintChecksum<WyhashFinal4ChecksumConfig>();
computeAndPrintChecksum<Murmur3_128_ChecksumConfig>();
computeAndPrintChecksum<Murmur3_32_ChecksumConfig>();
computeAndPrintChecksum<Murmur3_128_ChecksumConfig>(
std::numeric_limits<int>::max());
computeAndPrintChecksum<Murmur3_32_ChecksumConfig>(
std::numeric_limits<int>::max());
computeAndPrintChecksum<PolymurHash_2_0_ChecksumConfig>();
computeAndPrintChecksum<FarmHashNaChecksumConfig>();
computeAndPrintChecksum<FarmHashUoChecksumConfig>();
Expand Down
2,010 changes: 0 additions & 2,010 deletions reference-implementations/farmhash_na/out.txt

This file was deleted.

68 changes: 0 additions & 68 deletions reference-implementations/farmhash_na/reference_data.cpp

This file was deleted.

Loading

0 comments on commit ca58082

Please sign in to comment.