#include <EventProgress.h>
Public Member Functions | |
EventProgress () | |
EventProgress (unsigned long nEvents) | |
void | update (unsigned long event) |
~EventProgress () | |
Private Attributes | |
unsigned int | displayWidth |
time_t | lastUpdate |
unsigned long | nEvents |
time_t | startTime |
Definition at line 6 of file EventProgress.h.
EventProgress::EventProgress | ( | ) |
Definition at line 10 of file EventProgress.cc.
: nEvents(0), startTime(time(NULL)), lastUpdate(0), displayWidth(0) { }
EventProgress::EventProgress | ( | unsigned long | nEvents | ) |
Definition at line 15 of file EventProgress.cc.
: nEvents(_nEvents), startTime(time(NULL)), lastUpdate(0), displayWidth(int(std::log(nEvents + 0.5) / M_LN10 + 1)) { }
EventProgress::~EventProgress | ( | ) |
Definition at line 21 of file EventProgress.cc.
References gather_cfg::cout.
{ std::cout << " \r" << std::flush; }
void EventProgress::update | ( | unsigned long | event | ) |
Definition at line 26 of file EventProgress.cc.
References gather_cfg::cout, displayWidth, eta(), event(), lastUpdate, max(), nEvents, startTime, and cond::rpcobgas::time.
Referenced by JetTagMVATreeTrainer::analyze().
{ time_t currentTime = time(0); if (currentTime == lastUpdate) return; lastUpdate = currentTime; if (displayWidth) std::cout << "Event " << std::setw(displayWidth) << event; else std::cout << "Event " << event; if (nEvents) { unsigned long eta = (event >= 10) ? ((currentTime - startTime) * (nEvents - event) / event) : std::numeric_limits<unsigned long>::max(); std::cout << " (" << std::setw(2) << (event * 100 / nEvents) << "%), ETA "; if (eta >= 6000) std::cout << "##:##\r"; else std::cout << std::setw(2) << (eta / 60) << ":" << std::setfill('0') << std::setw(2) << (eta % 60); } std::cout << std::setfill(' ') << std::resetiosflags(std::ios::fixed) << std::resetiosflags(std::ios::scientific) << std::resetiosflags(std::ios::floatfield) << std::setprecision(8) << "\r" << std::flush; }
unsigned int EventProgress::displayWidth [private] |
Definition at line 18 of file EventProgress.h.
Referenced by update().
time_t EventProgress::lastUpdate [private] |
Definition at line 17 of file EventProgress.h.
Referenced by update().
unsigned long EventProgress::nEvents [private] |
Definition at line 15 of file EventProgress.h.
Referenced by update().
time_t EventProgress::startTime [private] |
Definition at line 16 of file EventProgress.h.
Referenced by update().