From d47316720024c2996df2ed10a8b111c5a8aa24a5 Mon Sep 17 00:00:00 2001 From: inxi-svn Date: Wed, 9 Apr 2014 06:30:46 +0000 Subject: [PATCH] quick check of cpu --- inxi | 34 +++++++++++++++++++++------------- 1 file changed, 21 insertions(+), 13 deletions(-) diff --git a/inxi b/inxi index 9c8254f..1c4ab64 100755 --- a/inxi +++ b/inxi @@ -3683,6 +3683,8 @@ get_cpu_data() nr = 0 count = 0 bArm = "false" + # ARM cpus are erratic in /proc/cpuinfo this hack can sometimes resolve it. Linux only. + sysSpeed="'$(get_cpu_speed_hack)'" } # TAKE STRONGER NOTE: \t+ does NOT always work, MUST be [ \t]+ # TAKE NOTE: \t+ will work for $FILE_CPUINFO, but SOME ARBITRARY FILE used for TESTING might contain SPACES! @@ -3760,7 +3762,12 @@ get_cpu_data() # note: assuming bogomips for arm at 1 x clock # http://en.wikipedia.org/wiki/BogoMips ARM could change so watch this # maybe add: && bArm == "true" but I think most of the bogomips roughly equal cpu speed if not amd/intel - if ( cpu[i, "bogomips"] != "" && cpu[i, "speed"] == "" ) { + # 2014-04-08: trying to use sysSpeed hack first, that is more accurate anyway. + if ( ( cpu[i, "speed"] == "" && sysSpeed != "" ) || \ + ( cpu[i, "speed"] == "" && cpu[i, "bogomips"] != "" && cpu[i, "bogomips"] < 50 ) ) { + cpu[i, "speed"] = sysSpeed + } + else if ( cpu[i, "bogomips"] != "" && cpu[i, "speed"] == "" ) { cpu[i, "speed"] = cpu[i, "bogomips"] } print cpu[i, "model"] "," cpu[i, "speed"] "," cpu[i, "cache"] "," cpu[i, "flags"] "," cpu[i, "bogomips"] "," cpu[nr, "vendor"] "," bArm @@ -3780,7 +3787,9 @@ get_cpu_data() printf("%s %s\n", max, "Mhz") } } - } ' $FILE_CPUINFO ) ) + } + ' $FILE_CPUINFO ) ) + IFS="$ORIGINAL_IFS" log_function_data 'cat' "$FILE_CPUINFO" elif [[ -n $BSD_TYPE ]];then @@ -9185,9 +9194,9 @@ print_short_data() ## assemble data for output local cpu_clock="${a_cpu_working[1]}" # old CPU3 # echo $cpu_clock - if [[ -z ${a_cpu_working[1]} || ${a_cpu_working[1]} < 50 ]];then - a_cpu_working[1]=$(get_cpu_speed_hack) - fi + # if [[ -z ${a_cpu_working[1]} || ${a_cpu_working[1]} < 50 ]];then + # a_cpu_working[1]=$(get_cpu_speed_hack) + # fi # this gets that weird min/max final array item, which almost never contains any data of use local min_max_clock_nu=$(( ${#A_CPU_DATA[@]} - 1 )) local min_max_clock=${A_CPU_DATA[$min_max_clock_nu]/.* Mhz/ Mhz} @@ -9495,16 +9504,15 @@ print_cpu_data() if [[ ${#A_CPU_DATA[@]} -gt 2 && $B_SHOW_CPU == 'true' ]];then cpu_clock_speed='' # null < verbosity level 5 else - if [[ -z ${a_cpu_working[1]} || ${a_cpu_working[1]} < 50 ]];then - a_cpu_working[1]=$(get_cpu_speed_hack) - if [[ -z ${a_cpu_working[1]} ]];then - if [[ -z ${cpu_data/*ARM*/} ]];then - temp1='ARM ' - fi - a_cpu_working[1]="N/A ${temp1}Error" + if [[ -z ${a_cpu_working[1]} ]];then + if [[ -z ${cpu_data/*ARM*/} ]];then + temp1=' (ARM)' fi + a_cpu_working[1]="N/A$temp1" + else + a_cpu_working[1]="${a_cpu_working[1]%.*} MHz" fi - cpu_data="$cpu_data ${C1}clocked at${C2} ${a_cpu_working[1]%.*} MHz" + cpu_clock_speed=" ${C1}clocked at${C2} ${a_cpu_working[1]}" fi cpu_2_data="$cpu_2_data$cpu_clock_speed" else