Commit fcffe0aa authored by Dennis Gläser's avatar Dennis Gläser
Browse files

[samplingstatus] allow reason-specific rejection

parent 0b2eae94
...@@ -25,6 +25,7 @@ ...@@ -25,6 +25,7 @@
#ifndef FRACKIT_SAMPLING_STATUS_HH #ifndef FRACKIT_SAMPLING_STATUS_HH
#define FRACKIT_SAMPLING_STATUS_HH #define FRACKIT_SAMPLING_STATUS_HH
#include <string>
#include <iomanip> #include <iomanip>
#include <iostream> #include <iostream>
#include <algorithm> #include <algorithm>
...@@ -67,9 +68,11 @@ public: ...@@ -67,9 +68,11 @@ public:
void reset() void reset()
{ {
headerPrinted_ = false; headerPrinted_ = false;
rejectedCount_ = 0; unspecifiedRejectedCount_ = 0;
count_.clear(); count_.clear();
targetCount_.clear(); targetCount_.clear();
rejectedCount_.clear();
} }
/*! /*!
...@@ -77,7 +80,9 @@ public: ...@@ -77,7 +80,9 @@ public:
*/ */
void resetCounters() void resetCounters()
{ {
for (auto& count : count_) count.second = 0; std::for_each(count_.begin(),
count_.end(),
[] (auto& idCountPair) { idCountPair.second = 0.0; });
} }
/*! /*!
...@@ -127,7 +132,16 @@ public: ...@@ -127,7 +132,16 @@ public:
*/ */
void increaseRejectedCounter() void increaseRejectedCounter()
{ {
rejectedCount_++; unspecifiedRejectedCount_++;
}
/*!
* \brief Increase counter of rejected samples
* with a specific rejection reason.
*/
void increaseRejectedCounter(const std::string& reason)
{
rejectedCount_[reason]++;
} }
/*! /*!
...@@ -139,7 +153,7 @@ public: ...@@ -139,7 +153,7 @@ public:
/*! /*!
* \brief Returns the overall entity count. * \brief Returns the overall entity count.
*/ */
std::size_t getCount() std::size_t getCount() const
{ {
return std::accumulate(count_.begin(), return std::accumulate(count_.begin(),
count_.end(), count_.end(),
...@@ -163,10 +177,12 @@ public: ...@@ -163,10 +177,12 @@ public:
std::size_t curCount = 0; std::size_t curCount = 0;
std::size_t curTargetCount = 0; std::size_t curTargetCount = 0;
std::size_t curRejectedCount = unspecifiedRejectedCount_;
for (const auto& pair : count_) curCount += pair.second; for (const auto& pair : count_) curCount += pair.second;
for (const auto& pair : targetCount_) curTargetCount += pair.second; for (const auto& pair : targetCount_) curTargetCount += pair.second;
for (const auto& pair : rejectedCount_) curRejectedCount += pair.second;
const auto ratio = 100.0*double(double(curCount)/double(curCount+rejectedCount_)); const auto ratio = 100.0*double(double(curCount)/double(curCount+curRejectedCount));
const auto progress = 100.0*double(curCount)/double(curTargetCount); const auto progress = 100.0*double(curCount)/double(curTargetCount);
std::cout << std::setprecision(2) << std::fixed; std::cout << std::setprecision(2) << std::fixed;
...@@ -174,7 +190,7 @@ public: ...@@ -174,7 +190,7 @@ public:
const auto progressNumChars = std::to_string(int(progress)).size() + 3; const auto progressNumChars = std::to_string(int(progress)).size() + 3;
const auto countString = std::to_string(curCount); const auto countString = std::to_string(curCount);
const auto rejectedCountString = std::to_string(rejectedCount_); const auto rejectedCountString = std::to_string(curRejectedCount);
using std::max; using std::max;
const std::size_t zero = 0; const std::size_t zero = 0;
...@@ -191,9 +207,11 @@ public: ...@@ -191,9 +207,11 @@ public:
private: private:
bool headerPrinted_ = false; bool headerPrinted_ = false;
std::size_t rejectedCount_ = 0;
std::unordered_map<std::size_t, std::size_t> count_; std::unordered_map<std::size_t, std::size_t> count_;
std::unordered_map<std::size_t, std::size_t> targetCount_; std::unordered_map<std::size_t, std::size_t> targetCount_;
std::unordered_map<std::string, std::size_t> rejectedCount_;
std::size_t unspecifiedRejectedCount_ = 0;
}; };
} // end namespace Frackit } // end namespace Frackit
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment