Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
RNTupleMetrics.cxx
Go to the documentation of this file.
1/// \file RNTupleMetrics.cxx
2/// \ingroup NTuple ROOT7
3/// \author Jakob Blomer <jblomer@cern.ch>
4/// \date 2019-08-27
5/// \warning This is part of the ROOT 7 prototype! It will change without notice. It might trigger earthquakes. Feedback
6/// is welcome!
7
8/*************************************************************************
9 * Copyright (C) 1995-2019, Rene Brun and Fons Rademakers. *
10 * All rights reserved. *
11 * *
12 * For the licensing terms see $ROOTSYS/LICENSE. *
13 * For the list of contributors see $ROOTSYS/README/CREDITS. *
14 *************************************************************************/
15
17
18#include <ostream>
19
20#include <iostream>
21
23{
24}
25
27{
28 return fName + kFieldSeperator + fUnit + kFieldSeperator + fDescription + kFieldSeperator + GetValueAsString();
29}
30
32{
33 return GetLocalCounter(name) != nullptr;
34}
35
38{
39 for (const auto &c : fCounters) {
40 if (c->GetName() == name)
41 return c.get();
42 }
43 return nullptr;
44}
45
48{
49 std::string prefix = fName + ".";
50 if (name.compare(0, prefix.length(), std::string_view(prefix)) != 0)
51 return nullptr;
52
53 auto innerName = name.substr(prefix.length());
54 if (auto counter = GetLocalCounter(innerName))
55 return counter;
56
57 for (auto m : fObservedMetrics) {
58 auto counter = m->GetCounter(innerName);
59 if (counter != nullptr)
60 return counter;
61 }
62
63 return nullptr;
64}
65
66void ROOT::Experimental::Detail::RNTupleMetrics::Print(std::ostream &output, const std::string &prefix) const
67{
68 if (!fIsEnabled) {
69 output << fName << " metrics disabled!" << std::endl;
70 return;
71 }
72
73 for (const auto &c : fCounters) {
74 output << prefix << fName << kNamespaceSeperator << c->ToString() << std::endl;
75 }
76 for (const auto c : fObservedMetrics) {
77 c->Print(output, prefix + fName + ".");
78 }
79}
80
82{
83 for (auto &c: fCounters)
84 c->Enable();
85 fIsEnabled = true;
86 for (auto m: fObservedMetrics)
87 m->Enable();
88}
89
91{
92 fObservedMetrics.push_back(&observee);
93}
#define c(i)
Definition RSha256.hxx:101
char name[80]
Definition TGX11.cxx:110
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.
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.
void Print(Option_t *option="") const override
Dump this marker with its attributes.
Definition TMarker.cxx:339
TMarker m
Definition textangle.C:8
static void output()