fix: count tested bits, print final results at end of input, show entropy chi2 p-value, add CMake header
This commit is contained in:
parent
e3ac03e4c0
commit
cfa31c9eaf
4 changed files with 50 additions and 32 deletions
75
QNGmeter.cpp
75
QNGmeter.cpp
|
|
@ -148,7 +148,10 @@ int main()
|
|||
|
||||
if (!newBuffer->empty()) {
|
||||
#pragma omp critical
|
||||
dataQueue.push(newBuffer);
|
||||
{
|
||||
dataQueue.push(newBuffer);
|
||||
bitsThroughputCount += 32.0 * newBuffer->size();
|
||||
}
|
||||
}
|
||||
}
|
||||
doExit = true; // Exit if stdin closes or reaches EOF
|
||||
|
|
@ -158,34 +161,8 @@ int main()
|
|||
#pragma omp section
|
||||
{
|
||||
// This section processes the enqueued data
|
||||
while (!doExit || !dataQueue.empty()) {
|
||||
shared_ptr<vector<uint32_t>> testBuffer = nullptr;
|
||||
#pragma omp critical
|
||||
{
|
||||
if (!dataQueue.empty()) {
|
||||
testBuffer = dataQueue.front();
|
||||
dataQueue.pop();
|
||||
}
|
||||
}
|
||||
|
||||
if (testBuffer != nullptr) {
|
||||
// Parallel processing of the testBuffer
|
||||
#pragma omp parallel sections num_threads(4)
|
||||
{
|
||||
#pragma omp section
|
||||
{ for (uint32_t value : *testBuffer) biasAndAc.InsertWord32(value); }
|
||||
#pragma omp section
|
||||
{ for (uint32_t value : *testBuffer) oqso.InsertWord32(value); }
|
||||
#pragma omp section
|
||||
{ for (uint32_t value : *testBuffer) serial.InsertWord32(value); }
|
||||
#pragma omp section
|
||||
{ for (uint32_t value : *testBuffer) entropy.InsertWord32(value); }
|
||||
}
|
||||
|
||||
// Display results
|
||||
time(&timeNow);
|
||||
if (difftime(timeNow, timePrev) >= 10)
|
||||
{
|
||||
// Computes the meta tests and meter, then prints the results table.
|
||||
auto report = [&]() {
|
||||
// calc rates
|
||||
#ifdef _WIN32
|
||||
QueryPerformanceCounter(&nowCount);
|
||||
|
|
@ -293,7 +270,7 @@ int main()
|
|||
cout << " | | 1/0 Balance " << setiosflags(ios::fixed) << setprecision(3) << showpos << biasAndAc.Bias.cumulativeBiasZScore << " " << setprecision(4) << noshowpos << CStat::ZtoP(biasAndAc.Bias.cumulativeBiasZScore) << " " << biasAndAc.Bias.P_Chi2 << " |" << endl;
|
||||
cout << " | | Serial Test " << setiosflags(ios::fixed) << setprecision(3) << showpos << serialZ << " " << setprecision(4) << noshowpos << serialP << " " << serial.P_Chi2 << " |" << endl;
|
||||
cout << " | | OQSO Test " << setiosflags(ios::fixed) << setprecision(3) << showpos << oqso.cumulativeZScore << " " << setprecision(4) << noshowpos << CStat::ZtoP(oqso.cumulativeZScore) << " " << oqso.P_Chi2 << " |" << endl;
|
||||
cout << " | | Entropy Test " << setiosflags(ios::fixed) << setprecision(3) << showpos << entropy.cumulativeZScore << " " << setprecision(4) << noshowpos << CStat::ZtoP(entropy.cumulativeZScore) << " " << serial.P_Chi2 << " |" << endl;
|
||||
cout << " | | Entropy Test " << setiosflags(ios::fixed) << setprecision(3) << showpos << entropy.cumulativeZScore << " " << setprecision(4) << noshowpos << CStat::ZtoP(entropy.cumulativeZScore) << " " << entropy.P_Chi2 << " |" << endl;
|
||||
cout << " | | H: " << setiosflags(ios::fixed) << setprecision(9) << entropy.E << " |" << endl;
|
||||
|
||||
cout << " | | |" << endl;
|
||||
|
|
@ -347,7 +324,8 @@ int main()
|
|||
default:
|
||||
cout << " | |";
|
||||
}
|
||||
cout << " " << setw(2) << i << "st AutoCorr " << setiosflags(ios::fixed) << setprecision(3) << showpos << biasAndAc.AC.cumulativeACZScore[i-1] << " " << setprecision(4) << noshowpos << CStat::ZtoP(biasAndAc.AC.cumulativeACZScore[i-1]) << " " << biasAndAc.AC.P_Chi2[i-1] << " |" << endl;
|
||||
const char *suffix = (i % 10 == 1 && i != 11) ? "st" : (i % 10 == 2 && i != 12) ? "nd" : (i % 10 == 3 && i != 13) ? "rd" : "th";
|
||||
cout << " " << setw(2) << i << suffix << " AutoCorr " << setiosflags(ios::fixed) << setprecision(3) << showpos << biasAndAc.AC.cumulativeACZScore[i-1] << " " << setprecision(4) << noshowpos << CStat::ZtoP(biasAndAc.AC.cumulativeACZScore[i-1]) << " " << biasAndAc.AC.P_Chi2[i-1] << " |" << endl;
|
||||
}
|
||||
cout << " +---------------------------+------------------------------------------------+" << endl;
|
||||
|
||||
|
|
@ -365,8 +343,39 @@ int main()
|
|||
|
||||
timePrev = timeNow;
|
||||
cout.flush();
|
||||
};
|
||||
|
||||
while (!doExit || !dataQueue.empty()) {
|
||||
shared_ptr<vector<uint32_t>> testBuffer = nullptr;
|
||||
#pragma omp critical
|
||||
{
|
||||
if (!dataQueue.empty()) {
|
||||
testBuffer = dataQueue.front();
|
||||
dataQueue.pop();
|
||||
}
|
||||
}
|
||||
|
||||
if (testBuffer != nullptr) {
|
||||
// Parallel processing of the testBuffer
|
||||
#pragma omp parallel sections num_threads(4)
|
||||
{
|
||||
#pragma omp section
|
||||
{ for (uint32_t value : *testBuffer) biasAndAc.InsertWord32(value); }
|
||||
#pragma omp section
|
||||
{ for (uint32_t value : *testBuffer) oqso.InsertWord32(value); }
|
||||
#pragma omp section
|
||||
{ for (uint32_t value : *testBuffer) serial.InsertWord32(value); }
|
||||
#pragma omp section
|
||||
{ for (uint32_t value : *testBuffer) entropy.InsertWord32(value); }
|
||||
}
|
||||
|
||||
bitsTestedCount += 32.0 * testBuffer->size();
|
||||
|
||||
// Display results every 10 seconds
|
||||
time(&timeNow);
|
||||
if (difftime(timeNow, timePrev) >= 10)
|
||||
report();
|
||||
|
||||
// End on an 'x' keypress
|
||||
#ifdef _WIN32
|
||||
if (kbhit())
|
||||
|
|
@ -390,6 +399,10 @@ int main()
|
|||
usleep(1000);
|
||||
}
|
||||
}
|
||||
|
||||
// Final results when the input ends (or on CTRL-C)
|
||||
time(&timeNow);
|
||||
report();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue