Skip to content

Commit af44789

Browse files
committed
Print the stats
1 parent c543c01 commit af44789

File tree

2 files changed

+63
-0
lines changed

2 files changed

+63
-0
lines changed

llvm/lib/Support/VirtualFileSystem.cpp

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2952,6 +2952,19 @@ void TracingFileSystem::printImpl(raw_ostream &OS, PrintType Type,
29522952
if (Type == PrintType::Summary)
29532953
return;
29542954

2955+
printIndent(OS, IndentLevel);
2956+
OS << "NumStatusCalls=" << NumStatusCalls << "\n";
2957+
printIndent(OS, IndentLevel);
2958+
OS << "NumOpenFileForReadCalls=" << NumOpenFileForReadCalls << "\n";
2959+
printIndent(OS, IndentLevel);
2960+
OS << "NumDirBeginCalls=" << NumDirBeginCalls << "\n";
2961+
printIndent(OS, IndentLevel);
2962+
OS << "NumGetRealPathCalls=" << NumGetRealPathCalls << "\n";
2963+
printIndent(OS, IndentLevel);
2964+
OS << "NumExistsCalls=" << NumExistsCalls << "\n";
2965+
printIndent(OS, IndentLevel);
2966+
OS << "NumIsLocalCalls=" << NumIsLocalCalls << "\n";
2967+
29552968
if (Type == PrintType::Contents)
29562969
Type = PrintType::Summary;
29572970
getUnderlyingFS().print(OS, Type, IndentLevel + 1);

llvm/unittests/Support/VirtualFileSystemTest.cpp

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3629,3 +3629,53 @@ TEST(TracingFileSystemTest, TracingWorks) {
36293629
EXPECT_EQ(TracingFS->NumExistsCalls, 1u);
36303630
EXPECT_EQ(TracingFS->NumIsLocalCalls, 1u);
36313631
}
3632+
3633+
TEST(TracingFileSystemTest, PrintOutput) {
3634+
auto InMemoryFS = makeIntrusiveRefCnt<vfs::InMemoryFileSystem>();
3635+
auto TracingFS =
3636+
makeIntrusiveRefCnt<vfs::TracingFileSystem>(std::move(InMemoryFS));
3637+
3638+
(void)TracingFS->status("/foo");
3639+
3640+
(void)TracingFS->openFileForRead("/foo");
3641+
(void)TracingFS->openFileForRead("/foo");
3642+
3643+
std::error_code EC;
3644+
(void)TracingFS->dir_begin("/foo", EC);
3645+
(void)TracingFS->dir_begin("/foo", EC);
3646+
(void)TracingFS->dir_begin("/foo", EC);
3647+
3648+
llvm::SmallString<128> RealPath;
3649+
(void)TracingFS->getRealPath("/foo", RealPath);
3650+
(void)TracingFS->getRealPath("/foo", RealPath);
3651+
(void)TracingFS->getRealPath("/foo", RealPath);
3652+
(void)TracingFS->getRealPath("/foo", RealPath);
3653+
3654+
(void)TracingFS->exists("/foo");
3655+
(void)TracingFS->exists("/foo");
3656+
(void)TracingFS->exists("/foo");
3657+
(void)TracingFS->exists("/foo");
3658+
(void)TracingFS->exists("/foo");
3659+
3660+
bool IsLocal;
3661+
(void)TracingFS->isLocal("/foo", IsLocal);
3662+
(void)TracingFS->isLocal("/foo", IsLocal);
3663+
(void)TracingFS->isLocal("/foo", IsLocal);
3664+
(void)TracingFS->isLocal("/foo", IsLocal);
3665+
(void)TracingFS->isLocal("/foo", IsLocal);
3666+
(void)TracingFS->isLocal("/foo", IsLocal);
3667+
3668+
std::string Output;
3669+
llvm::raw_string_ostream OS(Output);
3670+
TracingFS->print(OS);
3671+
3672+
ASSERT_EQ("TracingFileSystem\n"
3673+
"NumStatusCalls=1\n"
3674+
"NumOpenFileForReadCalls=2\n"
3675+
"NumDirBeginCalls=3\n"
3676+
"NumGetRealPathCalls=4\n"
3677+
"NumExistsCalls=5\n"
3678+
"NumIsLocalCalls=6\n"
3679+
" InMemoryFileSystem\n",
3680+
Output);
3681+
}

0 commit comments

Comments
 (0)