@@ -50,6 +50,22 @@ bool Application::CheckIfRunningBySuperUser()
50
50
return false ;
51
51
}
52
52
53
+ int Application::GetUsageStats ()
54
+ {
55
+ ZSwapDebug ZSwapDebugger;
56
+ std::cout << fmt::format (" Duplicate entries count: {0}." , ZSwapDebugger.GetDuplicateEntry ()) << std::endl;
57
+ std::cout << fmt::format (" Pool limit hit: {0}." , ZSwapDebugger.GetPoolLimitHit ()) << std::endl;
58
+ std::cout << fmt::format (" Pool total size: {0}." , ZSwapDebugger.GetPoolTotalSize ()) << std::endl;
59
+ std::cout << fmt::format (" Reject allocation failures: {0}." , ZSwapDebugger.GetRejectAllocFail ()) << std::endl;
60
+ std::cout << fmt::format (" Reject compression poor: {0}." , ZSwapDebugger.GetRejectCompressPoor ()) << std::endl;
61
+ std::cout << fmt::format (" Reject Kmemcache failures: {0}." , ZSwapDebugger.GetRejectKmemCacheFail ()) << std::endl;
62
+ std::cout << fmt::format (" Reject reclaim failures: {0}." , ZSwapDebugger.GetRejectReclaimFail ()) << std::endl;
63
+ std::cout << fmt::format (" Same filled pages count: {0}." , ZSwapDebugger.GetSameFilledPages ()) << std::endl;
64
+ std::cout << fmt::format (" Stored pages count: {0}." , ZSwapDebugger.GetStoredPages ()) << std::endl;
65
+ std::cout << fmt::format (" Written back pages count: {0}." , ZSwapDebugger.GetWrittenBackPages ()) << std::endl;
66
+ return 0 ;
67
+ }
68
+
53
69
void Application::ExecuteEnv ()
54
70
{
55
71
const std::string ZSwapEnabledEnv = CWrappers::GetEnv (" ZSWAP_ENABLED_VALUE" );
@@ -80,6 +96,7 @@ void Application::ExecuteCmdLine(const cxxopts::ParseResult& CmdLine)
80
96
int Application::Run (const cxxopts::ParseResult& CmdLine)
81
97
{
82
98
if (CheckIfRunningBySuperUser ()) return 1 ;
99
+ if (CmdLine.count (" stats" )) return GetUsageStats ();
83
100
if (CmdLine.count (" env" )) ExecuteEnv (); else ExecuteCmdLine (CmdLine);
84
101
return 0 ;
85
102
}
0 commit comments