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 <ostream>
18
19#include <iostream>
20
24
29
31{
32 return GetLocalCounter(name) != nullptr;
33}
34
37{
38 for (const auto &c : fCounters) {
39 if (c->GetName() == name)
40 return c.get();
41 }
42 return nullptr;
43}
44
47{
48 std::string prefix = fName + ".";
49 if (name.compare(0, prefix.length(), std::string_view(prefix)) != 0)
50 return nullptr;
51
52 auto innerName = name.substr(prefix.length());
53 if (auto counter = GetLocalCounter(innerName))
54 return counter;
55
56 for (auto m : fObservedMetrics) {
57 auto counter = m->GetCounter(innerName);
58 if (counter != nullptr)
59 return counter;
60 }
61
62 return nullptr;
63}
64
65void ROOT::Experimental::Detail::RNTupleMetrics::Print(std::ostream &output, const std::string &prefix) const
66{
67 if (!fIsEnabled) {
68 output << fName << " metrics disabled!" << std::endl;
69 return;
70 }
71
72 for (const auto &c : fCounters) {
73 output << prefix << fName << kNamespaceSeperator << c->ToString() << std::endl;
74 }
75 for (const auto c : fObservedMetrics) {
76 c->Print(output, prefix + fName + ".");
77 }
78}
79
81{
82 for (auto &c: fCounters)
83 c->Enable();
84 fIsEnabled = true;
85 for (auto m: fObservedMetrics)
86 m->Enable();
87}
88
#define c(i)
Definition RSha256.hxx:101
char name[80]
Definition TGX11.cxx:148
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.
std::vector< std::unique_ptr< RNTuplePerfCounter > > fCounters
bool Contains(const std::string &name) const
std::vector< RNTupleMetrics * > fObservedMetrics
void Print(std::ostream &output, const std::string &prefix="") const
static constexpr char kNamespaceSeperator
Symbol to split metrics name from counter / sub metrics name.
A performance counter with a name and a unit, which can be activated on demand.
virtual std::string GetValueAsString() const =0
static constexpr char kFieldSeperator
Symbol to split name, unit, description, and value when printing.
TMarker m
Definition textangle.C:8