Logo ROOT   6.30.04
Reference Guide
 All Namespaces Files Pages
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 
16 #include <ROOT/RNTupleMetrics.hxx>
17 
18 #include <ostream>
19 
20 ROOT::Experimental::Detail::RNTuplePerfCounter::~RNTuplePerfCounter()
21 {
22 }
23 
24 std::string ROOT::Experimental::Detail::RNTuplePerfCounter::ToString() const
25 {
26  return fName + kFieldSeperator + fUnit + kFieldSeperator + fDescription + kFieldSeperator + ValueToString();
27 }
28 
29 bool ROOT::Experimental::Detail::RNTupleMetrics::Contains(const std::string &name) const
30 {
31  for (const auto &c : fCounters) {
32  if (c->GetName() == name)
33  return true;
34  }
35  return false;
36 }
37 
38 void ROOT::Experimental::Detail::RNTupleMetrics::Print(std::ostream &output, const std::string &prefix) const
39 {
40  if (!fIsEnabled) {
41  output << fName << " metrics disabled!" << std::endl;
42  return;
43  }
44 
45  for (const auto &c : fCounters) {
46  output << prefix << fName << kNamespaceSeperator << c->ToString() << std::endl;
47  }
48  for (const auto c : fObservedMetrics) {
49  c->Print(output, prefix + fName + ".");
50  }
51 }
52 
53 void ROOT::Experimental::Detail::RNTupleMetrics::Enable()
54 {
55  for (auto &c: fCounters)
56  c->Enable();
57  fIsEnabled = true;
58  for (auto m: fObservedMetrics)
59  m->Enable();
60 }
61 
62 void ROOT::Experimental::Detail::RNTupleMetrics::ObserveMetrics(RNTupleMetrics &observee)
63 {
64  fObservedMetrics.push_back(&observee);
65 }