Merge pull request #62 from littlewu2508/master

uint32_t get_cpu_count() : support >255 threads
This commit is contained in:
Matt McCormick 2020-03-05 18:00:15 -05:00 committed by GitHub
commit d5007d4694
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 8 additions and 7 deletions

@ -45,7 +45,7 @@
#endif
float cpu_percentage( unsigned );
uint8_t get_cpu_count();
uint32_t get_cpu_count();
/** CPU percentage output mode.
*

@ -84,8 +84,9 @@ std::string mem_string( const MemoryStatus & mem_status,
break;
}
default: // Default mode, just show the used/total memory in MB
oss << static_cast< unsigned int >( mem_status.used_mem ) << '/'
<< static_cast< unsigned int >( mem_status.total_mem ) << "MB";
if(mem_status.used_mem>100000 && mem_status.total_mem>100000) oss<<static_cast<unsigned int>(mem_status.used_mem/1024)<<"/"<<static_cast<unsigned int>(mem_status.total_mem/1024)<<"GB";
else if(mem_status.used_mem<100000 && mem_status.total_mem>100000) oss<<static_cast<unsigned int>(mem_status.used_mem)<<"MB/"<<static_cast<unsigned int>(mem_status.total_mem/1024)<<"GB";
else oss<<static_cast<unsigned int>(mem_status.used_mem)<<"/"<<static_cast<unsigned int>(mem_status.total_mem)<<"MB";
}
if( use_colors )

@ -23,7 +23,7 @@
#include "cpu.h"
#include "luts.h"
uint8_t get_cpu_count()
uint32_t get_cpu_count()
{
return sysconf( _SC_NPROCESSORS_ONLN );
}

@ -21,7 +21,7 @@
#include "cpu.h"
uint8_t get_cpu_count()
uint32_t get_cpu_count()
{
return sysconf( _SC_NPROCESSORS_ONLN );
}

@ -31,9 +31,9 @@ static PDH_HCOUNTER cpuTotal;
#include "cpu.h"
#include "luts.h"
uint8_t get_cpu_count()
uint32_t get_cpu_count()
{
return static_cast< uint8_t >( std::thread::hardware_concurrency() );
return static_cast< uint32_t >( std::thread::hardware_concurrency() );
}
float cpu_percentage( unsigned cpu_usage_delay )