Added real time statistics to primeminer
parent
a68bb9392d
commit
69d1b97d97
|
@ -372,6 +372,7 @@ public:
|
|||
statistics.insert(std::pair<int,unsigned long>(retval,1));
|
||||
else
|
||||
statistics[retval]++;
|
||||
stats_running();
|
||||
} else
|
||||
std::cout << "error on read2b: " << len << " should be " << buf_size << std::endl;
|
||||
} break;
|
||||
|
@ -410,6 +411,38 @@ private:
|
|||
|
||||
boost::shared_mutex _mutex_master;
|
||||
boost::shared_mutex _mutex_working;
|
||||
|
||||
// Provides real time stats
|
||||
void stats_running() {
|
||||
if (!running) return;
|
||||
std::cout << std::fixed;
|
||||
std::cout << std::setprecision(0);
|
||||
boost::posix_time::ptime t_end = boost::posix_time::second_clock::universal_time();
|
||||
unsigned long rejects = 0;
|
||||
unsigned long stale = 0;
|
||||
unsigned long valid = 0;
|
||||
unsigned long blocks = 0;
|
||||
for (std::map<int,unsigned long>::iterator it = statistics.begin(); it != statistics.end(); ++it) {
|
||||
if (it->first < 0) stale += it->second;
|
||||
if (it->first == 0) rejects = it->second;
|
||||
if (it->first == 1) blocks = it->second;
|
||||
if (it->first > 1) valid += it->second;
|
||||
}
|
||||
for (std::map<int,unsigned long>::iterator it = statistics.begin(); it != statistics.end(); ++it)
|
||||
if (it->first > 1)
|
||||
std::cout << " " << it->first << "-CH: " << it->second << " (" <<
|
||||
((valid+blocks > 0) ? (static_cast<double>(it->second) / static_cast<double>(valid+blocks)) * 100.0 : 0.0) << "% | " <<
|
||||
((valid+blocks > 0) ? (static_cast<double>(it->second) / (static_cast<double>((t_end - t_start).total_seconds()) / 3600.0)) : 0.0) << "/hr), ";
|
||||
if (valid+blocks+rejects+stale > 0) {
|
||||
std::cout << "VL: " << valid+blocks << " (" << (static_cast<double>(valid+blocks) / static_cast<double>(valid+blocks+rejects+stale)) * 100.0 << "%), ";
|
||||
std::cout << "RJ: " << rejects << " (" << (static_cast<double>(rejects) / static_cast<double>(valid+blocks+rejects+stale)) * 100.0 << "%), ";
|
||||
std::cout << "ST: " << stale << " (" << (static_cast<double>(stale) / static_cast<double>(valid+blocks+rejects+stale)) * 100.0 << "%)" << std::endl;
|
||||
} else {
|
||||
std::cout << "VL: " << 0 << " (" << 0.0 << "%), ";
|
||||
std::cout << "RJ: " << 0 << " (" << 0.0 << "%), ";
|
||||
std::cout << "ST: " << 0 << " (" << 0.0 << "%)" << std::endl;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
/*********************************
|
||||
|
|
Loading…
Reference in New Issue