From d34821cb9500fc1c01febc7a35ccc0f81da77a23 Mon Sep 17 00:00:00 2001 From: WuYiyang Date: Sun, 23 Feb 2020 02:40:10 +0000 Subject: [PATCH 1/3] uint32_t get_cpu_count() : support >255 threads --- common/cpu.h | 2 +- linux/cpu.cc | 2 +- osx/cpu.cc | 2 +- windows/cpu.cc | 4 ++-- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/common/cpu.h b/common/cpu.h index 356b0d6..67bd601 100644 --- a/common/cpu.h +++ b/common/cpu.h @@ -45,7 +45,7 @@ #endif float cpu_percentage( unsigned ); -uint8_t get_cpu_count(); +uint32_t get_cpu_count(); /** CPU percentage output mode. * diff --git a/linux/cpu.cc b/linux/cpu.cc index 2fcc4c9..77110f1 100644 --- a/linux/cpu.cc +++ b/linux/cpu.cc @@ -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 ); } diff --git a/osx/cpu.cc b/osx/cpu.cc index d287756..f9023be 100644 --- a/osx/cpu.cc +++ b/osx/cpu.cc @@ -21,7 +21,7 @@ #include "cpu.h" -uint8_t get_cpu_count() +uint32_t get_cpu_count() { return sysconf( _SC_NPROCESSORS_ONLN ); } diff --git a/windows/cpu.cc b/windows/cpu.cc index 4a200a3..13f48cb 100644 --- a/windows/cpu.cc +++ b/windows/cpu.cc @@ -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 ) From fc78a0bdad043d4b660dff36e7e87b649fed3c8d Mon Sep 17 00:00:00 2001 From: WuYiyang Date: Sun, 1 Mar 2020 09:44:31 +0000 Subject: [PATCH 2/3] display mem in GB when >100000MB in default mode --- common/memory.cc | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/common/memory.cc b/common/memory.cc index 9dae11c..279bb8f 100644 --- a/common/memory.cc +++ b/common/memory.cc @@ -16,6 +16,7 @@ * limitations under the License. */ +#include #include #include "memory.h" @@ -84,8 +85,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<(mem_status.used_mem/1024)<<"/"<(mem_status.total_mem/1024)<<"GB"; + else if(mem_status.used_mem<100000 && mem_status.total_mem>100000) oss<(mem_status.used_mem)<<"MB/"<(mem_status.total_mem/1024)<<"GB"; + else oss<(mem_status.used_mem)<<"/"<(mem_status.total_mem)<<"MB"; } if( use_colors ) From 10ad0b29fde52965bff168ca4a0321452bf64653 Mon Sep 17 00:00:00 2001 From: WuYiyang Date: Sun, 1 Mar 2020 09:53:37 +0000 Subject: [PATCH 3/3] delete the accidentally added header --- common/memory.cc | 1 - 1 file changed, 1 deletion(-) diff --git a/common/memory.cc b/common/memory.cc index 279bb8f..423e6b2 100644 --- a/common/memory.cc +++ b/common/memory.cc @@ -16,7 +16,6 @@ * limitations under the License. */ -#include #include #include "memory.h"