Skip to content

Commit

Permalink
Added --memory and --memory-json cli options
Browse files Browse the repository at this point in the history
Added --memory and --memory-json cli options
  • Loading branch information
harold-b authored Sep 30, 2021
1 parent a4bac9f commit 8bb92eb
Showing 1 changed file with 31 additions and 1 deletion.
32 changes: 31 additions & 1 deletion src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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.
)";
Expand Down Expand Up @@ -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 );

Expand Down Expand Up @@ -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 );
Expand Down

0 comments on commit 8bb92eb

Please sign in to comment.