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 #endif
float cpu_percentage( unsigned ); float cpu_percentage( unsigned );
uint8_t get_cpu_count(); uint32_t get_cpu_count();
/** CPU percentage output mode. /** CPU percentage output mode.
* *

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

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

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

@ -31,9 +31,9 @@ static PDH_HCOUNTER cpuTotal;
#include "cpu.h" #include "cpu.h"
#include "luts.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 ) float cpu_percentage( unsigned cpu_usage_delay )