Jump to content

Having trouble reading CPU frequency on iOS

AdmiralDerp

Hi, sorry if this is the wrong board, but I am trying to port screenFetch to iOS. Part of the program outputs the CPU information as well as the CPU frequency. However, it seems that Apple removed the ability to query this in iOS 6.1.2?
As far as I can tell (sorry, I don't use OS X, so I have very little knowledge of how it works), you should be able to run "sysctl hw.cpufrequency" and have it display the information. However, I get nothing on this version of iOS (previous versions seemed to have it according to Google).
 

BKBrItbCMAAzHP5.png

 
Until I can find a work-around, I am stuck with this
 
BKBrxQOCEAAGnkk.png

 
Here is the current portion of code I am working with. If anyone knows a work around, I'd be very greatful!
 
 
# CPU Detection - Begindetectcpu () {	if [ "$distro" == "Mac OS X" ]; then cpu=$(echo $(sysctl -n machdep.cpu.brand_string))	elif [ "$distro" == "iPhone OS" ]; then cpu=$(sysctl -n hw.model)	elif [ "$distro" == "FreeBSD" ]; then cpu=$(sysctl -n hw.model)	elif [ "$distro" == "DragonflyBSD" ]; then cpu=$(sysctl -n hw.model)	elif [ "$distro" == "OpenBSD" ]; then cpu=$(sysctl -n hw.model | sed 's/@.*//')	else cpu=$(awk 'BEGIN{FS=":"} /model name/ { gsub(/  +/," ",$2); gsub(/^ /,"",$2); gsub(/\(R\)|\(TM\)|\(tm\)| Processor/,"",$2); print $2; exit }' /proc/cpuinfo | sed 's/ @/\n/' | head -1); fi	loc="/sys/devices/system/cpu/cpu0/cpufreq"	if [ -f $loc/bios_limit ];then		cpu_mhz=$(cat $loc/bios_limit | awk '{print $1/1000}')	elif [ -f $loc/scaling_max_freq ];then		cpu_mhz=$(cat $loc/scaling_max_freq | awk '{print $1/1000}')		else		cpu_mhz=$(awk -F':' '/cpu MHz/{ print int($2) }' /proc/cpuinfo | head -n 1)	fi	if [ -n "$cpu_mhz" ];then		if [ $cpu_mhz -gt 999 ];then			cpu_ghz=$(echo $cpu_mhz | awk '{print $1/1000}')			cpu="$cpu @ ${cpu_ghz}GHz"		else			cpu="$cpu @ ${cpu_mhz}MHz"		fi	fi	[[ "$verbosity" -eq "1" ]] && verboseOut "Finding current CPU...found as '$cpu'"}# CPU Detection - End


 
 
To be honest though, I have next to no knowledge of programing, just enough that I can understand what it's doing and enough to modify it to it's current state. Here's a link to the full source.
Link to comment
Share on other sites

Link to post
Share on other sites

iOS doesn't return the CPU frequency for some devices. 


The best thing you can do is estimate or guess it :)

Best regards Zahlio,
Unity asset developer - Game developer (http://playsurvive.com) - Computer Science student

Link to comment
Share on other sites

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×