Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion tree/ntupleutil/inc/ROOT/RNTupleInspector.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -502,7 +502,7 @@ public:
/////////////////////////////////////////////////////////////////////////////
/// \brief Print a string that represents the tree of the (sub)fields and columns of an RNTuple in a format which a
/// performance profile visualizer can render
void PrintSchemaProfile(ESchemaProfileFormat format, std::ostream &output = std::cout) const;
void PrintSchemaProfile([[maybe_unused]] ESchemaProfileFormat format, std::ostream &output = std::cout) const;
};
} // namespace Experimental
} // namespace ROOT
Expand Down
28 changes: 14 additions & 14 deletions tree/ntupleutil/src/RNTupleInspector.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -568,8 +568,7 @@ void ROOT::Experimental::RNTupleInspector::PrintFieldTreeAsDot(const ROOT::RFiel
namespace {

struct SpeedscopeFrame {
std::string fPrimaryString;
std::string fSecondaryString;
std::string fString;
std::uint64_t fOpeningPosition = 0;
std::uint64_t fClosingPosition = 0;
};
Expand All @@ -582,10 +581,7 @@ static void PrintSpeedscopeFrames(const std::vector<SpeedscopeFrame> &frames, st
output << " \"frames\":[\n";

for (std::size_t i = 0; i < frames.size(); ++i) {
output << " { \"name\":\"" << frames[i].fPrimaryString
<< "\", \"file\":\"Type: " << frames[i].fSecondaryString
<< ", Size: " << frames[i].fClosingPosition - frames[i].fOpeningPosition << "B\" }"
<< (i + 1 < frames.size() ? ",\n" : "\n");
output << " { \"name\":\"" << frames[i].fString << "\" }" << (i + 1 < frames.size() ? ",\n" : "\n");
}

output << " ]\n";
Expand Down Expand Up @@ -650,12 +646,12 @@ void ROOT::Experimental::RNTupleInspector::PrintSchemaProfile(ESchemaProfileForm
// Returns size of the visited field
auto visitFieldsRecursive = [&](auto &self, const ROOT::RFieldDescriptor &fieldDescriptor) -> std::size_t {
SpeedscopeFrame fieldSpeedscopeFrame;
fieldSpeedscopeFrame.fPrimaryString = tupleDescriptor.GetQualifiedFieldName(fieldDescriptor.GetId());
fieldSpeedscopeFrame.fSecondaryString = fieldDescriptor.GetTypeName();
fieldSpeedscopeFrame.fString =
tupleDescriptor.GetQualifiedFieldName(fieldDescriptor.GetId()) + " (" + fieldDescriptor.GetTypeName() + ")";
fieldSpeedscopeFrame.fOpeningPosition = positionCursor;
frames.push_back(fieldSpeedscopeFrame);

const std::size_t fieldSpeedscopeFrameIndex = frames.size() - 1;
std::size_t fieldSpeedscopeFrameIndex = frames.size() - 1;

std::size_t subTreeSize = 0;
const auto &childIds = fieldDescriptor.GetLinkIds();
Expand All @@ -670,10 +666,10 @@ void ROOT::Experimental::RNTupleInspector::PrintSchemaProfile(ESchemaProfileForm
std::size_t columnSize = columnInfo.GetCompressedSize();

SpeedscopeFrame columnSpeedscopeFrame;
columnSpeedscopeFrame.fPrimaryString = tupleDescriptor.GetQualifiedFieldName(fieldDescriptor.GetId()) +
" [col#" + std::to_string(columnDescriptor.GetPhysicalId()) + "]";
columnSpeedscopeFrame.fSecondaryString =
ROOT::Internal::RColumnElementBase::GetColumnTypeName(columnDescriptor.GetType());
columnSpeedscopeFrame.fString =
"[col#" + std::to_string(columnDescriptor.GetPhysicalId()) + "] " +
tupleDescriptor.GetQualifiedFieldName(fieldDescriptor.GetId()) + " (" +
ROOT::Internal::RColumnElementBase::GetColumnTypeName(columnDescriptor.GetType()) + ")";
columnSpeedscopeFrame.fOpeningPosition = positionCursor;
positionCursor += columnSize;
columnSpeedscopeFrame.fClosingPosition = positionCursor;
Expand All @@ -686,7 +682,11 @@ void ROOT::Experimental::RNTupleInspector::PrintSchemaProfile(ESchemaProfileForm
return subTreeSize;
};

visitFieldsRecursive(visitFieldsRecursive, rootFieldDescriptor);
const auto &topLevelIds = rootFieldDescriptor.GetLinkIds();
for (const auto &childId : topLevelIds) {
const auto &childFieldDescriptor = tupleDescriptor.GetFieldDescriptor(childId);
visitFieldsRecursive(visitFieldsRecursive, childFieldDescriptor);
}

PrintSpeedscopeFrames(frames, output);
}
21 changes: 9 additions & 12 deletions tree/ntupleutil/test/ntuple_inspector.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -882,15 +882,14 @@ TEST(RNTupleInspector, SchemaProfile)
std::ostringstream schemaProfileStream;
inspector->PrintSchemaProfile(ROOT::Experimental::ESchemaProfileFormat::kSpeedscopeJSON, schemaProfileStream);
const std::string schemaProfile = schemaProfileStream.str();
const std::string expected = R"({
const std::string expected = R"foo({
"$schema":"https://www.speedscope.app/file-format-schema.json",
"shared":{
"frames":[
{ "name":"", "file":"Type: , Size: 80B" },
{ "name":"float1", "file":"Type: float, Size: 40B" },
{ "name":"float1 [col#0]", "file":"Type: SplitReal32, Size: 40B" },
{ "name":"int", "file":"Type: std::int32_t, Size: 40B" },
{ "name":"int [col#1]", "file":"Type: SplitInt32, Size: 40B" }
{ "name":"float1 (float)" },
{ "name":"[col#0] float1 (SplitReal32)" },
{ "name":"int (std::int32_t)" },
{ "name":"[col#1] int (SplitInt32)" }
]
},
"profiles":[
Expand All @@ -903,18 +902,16 @@ TEST(RNTupleInspector, SchemaProfile)
"events":[
{"type":"O","frame":0,"at":0},
{"type":"O","frame":1,"at":0},
{"type":"O","frame":2,"at":0},
{"type":"C","frame":2,"at":40},
{"type":"C","frame":1,"at":40},
{"type":"C","frame":0,"at":40},
{"type":"O","frame":2,"at":40},
{"type":"O","frame":3,"at":40},
{"type":"O","frame":4,"at":40},
{"type":"C","frame":4,"at":80},
{"type":"C","frame":3,"at":80},
{"type":"C","frame":0,"at":80}
{"type":"C","frame":2,"at":80}
]
}
]
}
)";
)foo";
EXPECT_EQ(schemaProfile, expected);
}
Loading