aboutsummaryrefslogtreecommitdiff
path: root/llvm/unittests/ProfileData/MemProfTest.cpp
diff options
context:
space:
mode:
authorKazu Hirata <kazu@google.com>2024-12-04 19:23:27 -0800
committerGitHub <noreply@github.com>2024-12-04 19:23:27 -0800
commit7b8cf147addf7d3fb4630475c40153226f5fdbd0 (patch)
treea16f736c4c3b646c92092bcc8a646ece933cfd92 /llvm/unittests/ProfileData/MemProfTest.cpp
parentf98c9a9b3665c75a6bf01577734f16185710009d (diff)
downloadllvm-7b8cf147addf7d3fb4630475c40153226f5fdbd0.zip
llvm-7b8cf147addf7d3fb4630475c40153226f5fdbd0.tar.gz
llvm-7b8cf147addf7d3fb4630475c40153226f5fdbd0.tar.bz2
[memprof] Update YAML traits for writer purposes (#118720)
For Frames, we prefer the inline notation for the brevity. For PortableMemInfoBlock, we go through all member fields and print out those that are populated.
Diffstat (limited to 'llvm/unittests/ProfileData/MemProfTest.cpp')
-rw-r--r--llvm/unittests/ProfileData/MemProfTest.cpp36
1 files changed, 36 insertions, 0 deletions
diff --git a/llvm/unittests/ProfileData/MemProfTest.cpp b/llvm/unittests/ProfileData/MemProfTest.cpp
index 2f8589b..83383ee 100644
--- a/llvm/unittests/ProfileData/MemProfTest.cpp
+++ b/llvm/unittests/ProfileData/MemProfTest.cpp
@@ -807,4 +807,40 @@ HeapProfileRecords:
EXPECT_THAT(Record.CallSiteIds,
ElementsAre(hashCallStack(CS3), hashCallStack(CS4)));
}
+
+template <typename T> std::string serializeInYAML(T &Val) {
+ std::string Out;
+ llvm::raw_string_ostream OS(Out);
+ llvm::yaml::Output Yout(OS);
+ Yout << Val;
+ return Out;
+}
+
+TEST(MemProf, YAMLWriterFrame) {
+ Frame F(11, 22, 33, true);
+
+ std::string Out = serializeInYAML(F);
+ EXPECT_EQ(Out, R"YAML(---
+{ Function: 11, LineOffset: 22, Column: 33, Inline: true }
+...
+)YAML");
+}
+
+TEST(MemProf, YAMLWriterMIB) {
+ MemInfoBlock MIB;
+ MIB.AllocCount = 111;
+ MIB.TotalSize = 222;
+ MIB.TotalLifetime = 333;
+ MIB.TotalLifetimeAccessDensity = 444;
+ PortableMemInfoBlock PMIB(MIB, llvm::memprof::getHotColdSchema());
+
+ std::string Out = serializeInYAML(PMIB);
+ EXPECT_EQ(Out, R"YAML(---
+AllocCount: 111
+TotalSize: 222
+TotalLifetime: 333
+TotalLifetimeAccessDensity: 444
+...
+)YAML");
+}
} // namespace