-
Notifications
You must be signed in to change notification settings - Fork 46
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
063977e
commit ba150c1
Showing
3 changed files
with
39 additions
and
1 deletion.
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,37 @@ | ||
#define NO_UEFI | ||
|
||
#include "../src/kangaroo_twelve.h" | ||
|
||
#include "gtest/gtest.h" | ||
|
||
#include <chrono> | ||
|
||
|
||
TEST(TestCoreK12, PerformanceDigest32Of1GB) | ||
{ | ||
constexpr size_t bytesPerGigaByte = 1024 * 1024 * 1024; | ||
constexpr size_t repN = 1; | ||
constexpr size_t inputN = bytesPerGigaByte; | ||
constexpr size_t outputN = 32; | ||
|
||
char* inputPtr = new char[inputN]; | ||
for (size_t i = 0; i < 100; ++i) | ||
{ | ||
unsigned int pos, val; | ||
_rdrand32_step(&pos); | ||
_rdrand32_step(&val); | ||
inputPtr[pos % inputN] = val & 0xff; | ||
} | ||
char outputArray[outputN]; | ||
|
||
auto startTime = std::chrono::high_resolution_clock::now(); | ||
for (size_t i = 0; i < repN; ++i) | ||
KangarooTwelve(inputPtr, inputN, outputArray, outputN); | ||
auto durationMilliSec = std::chrono::duration_cast<std::chrono::milliseconds>(std::chrono::high_resolution_clock::now() - startTime); | ||
|
||
double bytePerMilliSec = double(repN * inputN) / double(durationMilliSec.count()); | ||
double gigaBytePerSec = bytePerMilliSec * (1000.0 / bytesPerGigaByte); | ||
std::cout << "K12 of 1 GB to 32 Byte digest: " << gigaBytePerSec << " GB/sec = " << 1.0 / gigaBytePerSec << " sec/GB" << std::endl; | ||
|
||
delete [] inputPtr; | ||
} |
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