From 8bb92ebcbf6265bbafbbd0211ee889701ddcaa1b Mon Sep 17 00:00:00 2001 From: Harold Brenes Date: Thu, 30 Sep 2021 18:18:06 -0500 Subject: [PATCH] Added --memory and --memory-json cli options Added --memory and --memory-json cli options --- src/main.cpp | 32 +++++++++++++++++++++++++++++++- 1 file changed, 31 insertions(+), 1 deletion(-) diff --git a/src/main.cpp b/src/main.cpp index a62f5189..7b62ef87 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -121,6 +121,11 @@ R"( This is useful when running multiple simultaneous instances of bladebit as you can manually assign thread affinity yourself when launching bladebit. + + --memory : Display system memory available, in bytes, and the + required memory to run Bladebit, in bytes. + + --memory-json : Same as --memory, but formats the output as json. --version : Display current version. )"; @@ -264,7 +269,7 @@ void ParseCommandLine( int argc, const char* argv[], Config& cfg ) const char* val = value(); int64 v = 0; - int r = sscanf( val, "%lli", &v ); + int r = sscanf( val, "%lld", &v ); if( r != 1 ) Fatal( "Invalid value for argument '%s'.", arg ); @@ -371,6 +376,31 @@ void ParseCommandLine( int argc, const char* argv[], Config& cfg ) { Log::SetVerbose( true ); } + else if( check( "--memory" ) ) + { + // #TODO: Get this value from Memplotter + const size_t requiredMem = 416ull GB; + const size_t availableMem = SysHost::GetAvailableSystemMemory(); + const size_t totalMem = SysHost::GetTotalSystemMemory(); + + Log::Line( "required : %llu", requiredMem ); + Log::Line( "total : %llu", totalMem ); + Log::Line( "available: %llu", availableMem ); + + exit( 0 ); + } + else if( check( "--memory-json" ) ) + { + // #TODO: Get this value from Memplotter + const size_t requiredMem = 416ull GB; + const size_t availableMem = SysHost::GetAvailableSystemMemory(); + const size_t totalMem = SysHost::GetTotalSystemMemory(); + + Log::Line( "{ \"required\": %llu, \"total\": %llu, \"available\": %llu }", + requiredMem, totalMem, availableMem ); + + exit( 0 ); + } else if( check( "--version" ) ) { Log::Line( BLADEBIT_VERSION_STR );