37 static std::mutex mutex;
43struct RSuppressMetricsRaii {
45 RSuppressMetricsRaii(
const RSuppressMetricsRaii &
other) =
delete;
46 RSuppressMetricsRaii &operator=(
const RSuppressMetricsRaii &
other) =
delete;
58 return fName + kFieldSeperator + fUnit + kFieldSeperator + fDescription + kFieldSeperator + GetValueAsString();
63 return GetLocalCounter(
name) !=
nullptr;
69 for (
const auto &
c : fCounters) {
70 if (
c->GetName() ==
name)
79 std::string prefix = fName +
".";
80 if (
name.compare(0, prefix.length(), std::string_view(prefix)) != 0)
84 if (
auto counter = GetLocalCounter(
innerName))
87 for (
auto m : fObservedMetrics) {
89 if (counter !=
nullptr)
99 output << fName <<
" metrics disabled!\n";
103 for (
const auto &
c : fCounters) {
104 output << prefix << fName << kNamespaceSeperator <<
c->ToString() <<
'\n';
106 for (
const auto c : fObservedMetrics) {
107 c->Print(output, prefix + fName +
".");
113 for (
auto &
c: fCounters)
116 for (
auto m: fObservedMetrics)
122 fObservedMetrics.push_back(&
observee);
138 if (!fIsEnabled || fExportPath.empty())
145 std::vector<std::pair<std::string, const RNTuplePerfCounter *>> &
counters,
const std::string &prefix)
const
147 constexpr char kSeparator =
'_';
156 for (
const auto &counter : fCounters)
159 for (
const auto *
observed : fObservedMetrics)
168 std::vector<std::pair<std::string, const RNTuplePerfCounter *>>
counters;
193 merger.SetMergeOptions(std::string_view(
"rntuple.MergingMode=Union"));
195 if (!
merger.OutputFile(fExportPath.c_str(),
"UPDATE")) {
202 <<
"cannot merge metrics for '" << fNTupleName <<
"' into '" << fExportPath <<
"'";
#define R__LOG_ERROR(...)
ROOT::Detail::TRangeCast< T, true > TRangeDynCast
TRangeDynCast is an adapter class that allows the typed iteration through a TCollection.
#define R__ASSERT(e)
Checks condition e and reports a fatal error if it's false.
R__EXTERN TSystem * gSystem
A metric element that computes its floating point value from other counters.
A collection of Counter objects with a name, a unit, and a description.
const RNTuplePerfCounter * GetCounter(std::string_view name) const
Searches this object and all the observed sub metrics.
void ObserveMetrics(RNTupleMetrics &observee)
const RNTuplePerfCounter * GetLocalCounter(std::string_view name) const
Searches counters registered in this object only. Returns nullptr if name is not found.
void CollectCounters(std::vector< std::pair< std::string, const RNTuplePerfCounter * > > &counters, const std::string &prefix="") const
Retrieves each counter of the observed metrics down to the class instances which own the counters and...
static std::string GetMetricsExportPath()
bool Contains(const std::string &name) const
void Print(std::ostream &output, const std::string &prefix="") const
A performance counter with a name and a unit, which can be activated on demand.
std::string ToString() const
virtual ~RNTuplePerfCounter()
static std::unique_ptr< RNTupleModel > Create()
static std::unique_ptr< RNTupleWriter > Append(std::unique_ptr< ROOT::RNTupleModel > model, std::string_view ntupleName, TDirectory &fileOrDirectory, const ROOT::RNTupleWriteOptions &options=ROOT::RNTupleWriteOptions())
Creates an RNTupleWriter that writes into an existing TFile or TDirectory, without overwriting its co...
This class provides file copy and merging services.
@ kAll
Merge all type of objects (default)
@ kIncremental
Merge the input file with the content of the output file (if already existing).
A TMemFile is like a normal TFile except that it reads and writes only from memory.
virtual const char * Getenv(const char *env)
Get environment variable.
ROOT::RLogChannel & NTupleLog()
Log channel for RNTuple diagnostics.