-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
81c43fe
commit 2cda9d4
Showing
1 changed file
with
54 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
#include <iostream> | ||
#include <cstdint> | ||
#include <memory> | ||
|
||
#include "AvalancheTest.hpp" | ||
#include "HashFunction.hpp" | ||
#include "Operator.hpp" | ||
#include "XorLeftShift.hpp" | ||
#include "XorRightShift.hpp" | ||
#include "Multiply.hpp" | ||
#include "AddShift.hpp" | ||
#include "Masking.hpp" | ||
#include "Multiply.hpp" | ||
#include "log.h" | ||
|
||
|
||
int main() | ||
{ | ||
CLUTCHLOG(progress, "Set config"); | ||
clutchlog_config(); // common config | ||
auto& log = clutchlog::logger(); | ||
log.threshold("XDebug"); | ||
|
||
// The size of the values to manipulate is 57 bits. | ||
size_t value_size{32}; | ||
using myuint = uint32_t; | ||
|
||
CLUTCHLOG(progress, "Try HashFunc"); | ||
// Create an instance of HashFunction with a value size of 64 bits | ||
HashFunction<myuint> hashFunc(value_size, "hash"); | ||
|
||
// Add shift operators | ||
hashFunc.add_operator(std::make_unique<XorRightShift<myuint>>(16, value_size)); | ||
hashFunc.add_operator(std::make_unique<Multiply<myuint>>(0x7feb352dU, value_size)); | ||
hashFunc.add_operator(std::make_unique<XorRightShift<myuint>>(15, value_size)); | ||
hashFunc.add_operator(std::make_unique<Multiply<myuint>>(0x846ca68bU, value_size)); | ||
hashFunc.add_operator(std::make_unique<XorRightShift<myuint>>(16, value_size)); | ||
|
||
CLUTCHLOG(note, "Complete with masks"); | ||
// Complete with masks if necessary | ||
hashFunc.complete_with_masks(); | ||
|
||
// Print the string representation of the hash function | ||
std::cout << hashFunc.to_string() << std::endl; | ||
|
||
StrictAvalancheTest<myuint> strict_test{hashFunc}; | ||
CLUTCHLOG(progress, "Run SoftAvalancheTest"); | ||
for (size_t i = 0; i < 20; i++) | ||
{ | ||
CLUTCHLOG(note, " 10 000 iterations:\t" << strict_test.run(value_size * 10000UL)); | ||
} | ||
|
||
return 0; | ||
} |