Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
RNTupleMetrics.cxx
Go to the documentation of this file.
1/// \file RNTupleMetrics.cxx
2/// \author Jakob Blomer <jblomer@cern.ch>
3/// \date 2019-08-27
4/// \warning This is part of the ROOT 7 prototype! It will change without notice. It might trigger earthquakes. Feedback
5/// is welcome!
6
7/*************************************************************************
8 * Copyright (C) 1995-2019, Rene Brun and Fons Rademakers. *
9 * All rights reserved. *
10 * *
11 * For the licensing terms see $ROOTSYS/LICENSE. *
12 * For the list of contributors see $ROOTSYS/README/CREDITS. *
13 *************************************************************************/
14
16
17#include <TSystem.h>
18
19#include <ostream>
20
21#include <iostream>
22
26
28{
29 return fName + kFieldSeperator + fUnit + kFieldSeperator + fDescription + kFieldSeperator + GetValueAsString();
30}
31
33{
34 return GetLocalCounter(name) != nullptr;
35}
36
39{
40 for (const auto &c : fCounters) {
41 if (c->GetName() == name)
42 return c.get();
43 }
44 return nullptr;
45}
46
49{
50 std::string prefix = fName + ".";
51 if (name.compare(0, prefix.length(), std::string_view(prefix)) != 0)
52 return nullptr;
53
54 auto innerName = name.substr(prefix.length());
55 if (auto counter = GetLocalCounter(innerName))
56 return counter;
57
58 for (auto m : fObservedMetrics) {
59 auto counter = m->GetCounter(innerName);
60 if (counter != nullptr)
61 return counter;
62 }
63
64 return nullptr;
65}
66
67void ROOT::Experimental::Detail::RNTupleMetrics::Print(std::ostream &output, const std::string &prefix) const
68{
69 if (!fIsEnabled) {
70 output << fName << " metrics disabled!\n";
71 return;
72 }
73
74 for (const auto &c : fCounters) {
75 output << prefix << fName << kNamespaceSeperator << c->ToString() << '\n';
76 }
77 for (const auto c : fObservedMetrics) {
78 c->Print(output, prefix + fName + ".");
79 }
80}
81
83{
84 for (auto &c: fCounters)
85 c->Enable();
86 fIsEnabled = true;
87 for (auto m: fObservedMetrics)
88 m->Enable();
89}
90
95
97{
98 static const std::string path = []() -> std::string {
99 if (const char *env = gSystem->Getenv("ROOT_EXPORT_RNTUPLE_METRICS"); env && *env)
100 return env;
101 return "";
102 }();
103 return path;
104}
#define c(i)
Definition RSha256.hxx:101
ROOT::Detail::TRangeCast< T, true > TRangeDynCast
TRangeDynCast is an adapter class that allows the typed iteration through a TCollection.
char name[80]
Definition TGX11.cxx:148
R__EXTERN TSystem * gSystem
Definition TSystem.h:582
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.
static const 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.
virtual const char * Getenv(const char *env)
Get environment variable.
Definition TSystem.cxx:1680
TMarker m
Definition textangle.C:8