Print CPU usage without decimal point if >= 100

Also:
add --colours shortopt to help/readme,
Conform to coding style.
This commit is contained in:
Josh Davies 2016-06-27 08:00:09 +01:00
parent 4a2c4efb9a
commit b7d2d2a73e
2 changed files with 9 additions and 2 deletions

@ -116,7 +116,7 @@ The full usage::
Available options:
-h, --help
Prints this help message
--colors
-c, --colors
Use tmux colors in output
--powerline-right
Use powerline symbols throughout the output, DO NOT reset background color at the end, enables --colors

@ -51,10 +51,17 @@ std::string cpu_string( CPU_MODE cpu_mode, unsigned int cpu_usage_delay, unsigne
percentage = cpu_percentage( cpu_usage_delay );
// set multiplier to number of threads ?
if ( cpu_mode == CPU_MODE_THREADS ) {
if ( cpu_mode == CPU_MODE_THREADS )
{
multiplier = get_cpu_count();
}
// if percentage*multiplier >= 100, remove decimal point to keep number short
if ( percentage*multiplier >= 100.0f )
{
oss.precision( 0 );
}
if( use_colors )
{
unsigned int percent = static_cast<unsigned int>( percentage );