RDF progress helper.
This class provides callback functions to the RDataFrame. The event statistics (including elapsed time, currently processed file, currently processed events, the rate of event processing and an estimated remaining time (per file being processed)) are recorded and printed in the terminal every m events and every n seconds. ProgressHelper::operator()(unsigned int, T&) is thread safe, and can be used as a callback in MT mode. ProgressBar should be added after creating the dataframe object (df):
alternatively RDataFrame can be cast to an RNode first giving it more flexibility. For example, it can be called at any computational node, such as Filter or Define, not only the head node, with no change to the ProgressBar function itself:
Definition at line 332 of file RDFHelpers.hxx.
Public Member Functions | |
| ProgressHelper (ProgressHelper &&)=delete | |
| ProgressHelper (ProgressHelper const &)=delete | |
| ProgressHelper (std::size_t increment, unsigned int totalFiles, unsigned int printInterval=0, bool useColors=true) | |
| Create a progress helper. | |
| ~ProgressHelper ()=default | |
| template<typename T > | |
| void | operator() (unsigned int, T &) |
| Thread-safe callback for RDataFrame. | |
| ProgressHelper & | operator= (ProgressHelper &&)=delete |
| ProgressHelper & | operator= (ProgressHelper const &)=delete |
| void | PrintStatsFinal () const |
| void | RegisterNewSample (unsigned int, const ROOT::RDF::RSampleInfo &id) |
| Register a new sample for completion statistics. | |
Private Member Functions | |
| std::size_t | ComputeTotalEvents () const |
| Compute total events in all open files. | |
| double | EvtPerSec () const |
| Compute a running mean of events/s. | |
| void | PrintProgressAndStats (std::ostream &stream, std::size_t currentEventCount, std::chrono::seconds totalElapsedSeconds) const |
| Print event and time statistics. | |
| std::pair< std::size_t, std::chrono::seconds > | RecordEvtCountAndTime () |
| Record current event counts and time stamp, populate evts/s statistics array. | |
| void | Update () |
| Record number of events processed and update progress bar. | |
Private Attributes | |
| std::chrono::time_point< std::chrono::system_clock > const | fBeginTime = std::chrono::system_clock::now() |
| std::array< double, 10 > | fEventsPerSecondStatistics |
| unsigned int | fEventsPerSecondStatisticsCounter {0} |
| std::size_t const | fIncrement |
| bool const | fIsTTY |
| std::chrono::time_point< std::chrono::system_clock > | fLastPrintTime = fBeginTime |
| std::size_t | fLastProcessedEvents {0} |
| unsigned int const | fNColumns |
| std::chrono::seconds const | fPrintInterval |
| std::atomic< std::size_t > | fProcessedEvents {0} |
| std::map< std::string, ULong64_t > | fSampleNameToEventEntries |
| std::mutex | fSampleNameToEventEntriesMutex |
| unsigned int const | fTotalFiles |
| std::mutex | fUpdateMutex |
| bool const | fUseShellColours |
#include <ROOT/RDFHelpers.hxx>
| ROOT::RDF::Experimental::ProgressHelper::ProgressHelper | ( | std::size_t | increment, |
| unsigned int | totalFiles, | ||
| unsigned int | printInterval = 0, | ||
| bool | useColors = true ) |
Create a progress helper.
| increment | RDF callbacks are called every n events. Pass this n here. |
| totalFiles | number of files read in the RDF. |
| printInterval | Update stats every n seconds. |
| useColors | Use shell colour codes to colour the output. Automatically disabled when we are not writing to a tty. |
Definition at line 178 of file RDFHelpers.cxx.
|
delete |
|
delete |
|
default |
|
private |
Compute total events in all open files.
Definition at line 229 of file RDFHelpers.cxx.
|
private |
Compute a running mean of events/s.
Definition at line 214 of file RDFHelpers.cxx.
|
inline |
Thread-safe callback for RDataFrame.
It will record elapsed times and event statistics, and print a progress bar every n seconds (set by the fPrintInterval).
| slot | Ignored. |
| value | Ignored. |
Definition at line 385 of file RDFHelpers.hxx.
|
delete |
|
delete |
|
private |
Print event and time statistics.
Definition at line 261 of file RDFHelpers.cxx.
| void ROOT::RDF::Experimental::ProgressHelper::PrintStatsFinal | ( | ) | const |
Definition at line 356 of file RDFHelpers.cxx.
|
private |
Record current event counts and time stamp, populate evts/s statistics array.
The function assumes that a lock on the update mutex is held.
Definition at line 240 of file RDFHelpers.cxx.
| void ROOT::RDF::Experimental::ProgressHelper::RegisterNewSample | ( | unsigned int | , |
| const ROOT::RDF::RSampleInfo & | id ) |
Register a new sample for completion statistics.
Definition at line 207 of file RDFHelpers.cxx.
|
private |
Record number of events processed and update progress bar.
This function will atomically record elapsed times and event statistics, and one thread will udpate the progress bar every n seconds (set by the fPrintInterval).
Definition at line 397 of file RDFHelpers.cxx.
|
private |
Definition at line 353 of file RDFHelpers.hxx.
|
private |
Definition at line 350 of file RDFHelpers.hxx.
|
private |
Definition at line 351 of file RDFHelpers.hxx.
|
private |
Definition at line 346 of file RDFHelpers.hxx.
Definition at line 341 of file RDFHelpers.hxx.
|
private |
Definition at line 354 of file RDFHelpers.hxx.
|
private |
Definition at line 345 of file RDFHelpers.hxx.
Definition at line 347 of file RDFHelpers.hxx.
|
private |
Definition at line 355 of file RDFHelpers.hxx.
|
private |
Definition at line 344 of file RDFHelpers.hxx.
|
private |
Definition at line 362 of file RDFHelpers.hxx.
|
mutableprivate |
Definition at line 361 of file RDFHelpers.hxx.
Definition at line 348 of file RDFHelpers.hxx.
|
private |
Definition at line 359 of file RDFHelpers.hxx.
Definition at line 342 of file RDFHelpers.hxx.