[HTC 10 Guides, News, & Discussion] Haldi4803:
How i Benchmark Governors.

Intro

I'm sure you've seen these Graphs that show CPU time in State that i use for Governor Benchmarking. If not click here.

There is no magic behind that. Better Battery Stats and many other CPU Control apps do the exact same thing, read the "Time_in_State" file found in /sys/devices/system/cpu/cpu0/cpufreq/stats/ The only difference is, i copy a version of this file before i start testing, and after i'm done with my benchmark. So by using advanced mathematics (subtraction in this case) i have exactly the time spent in state X during my benchmarking procedure and not since boot. Jep, BetterBatteryStats does the same if you create a custom timestamp.

Another interesting file in the same folder is the "Total_trans" While Time_in_State shows Frequency 307Mhz has been used for 30 seconds the Transitions tell the amount of jumps the CPU governor has done. Did it stay on 307mhz for 30 seconds, or did it jump from 307 to X and back to 307 for how many times?

Sadly we don't have advanced Statistics that show the exact jump but only one Value, the Total Amount of Jumps done. This is still interesting if you compare governors agains each other.

Talking about Advanced Transitions the GPU does a way better job there, but this makes it all the more complicated. The "Trans_stat" file found in /sys/devices/soc/b00000.qcom,kgsl-3d0/devfreq/b00000.qcom,kgsl-3d0/trans_stat shows exactly how many times Frequency 133 jumped to 214 or 315 or 401 or 510 or 560 or 624, it also shows how many times frequency 624 dropped to 560 or 510 or 401 or 315 or 214 or 133. Yeah... you get it.... quit a bit of numbers there. On top of that you get the Normal Time in State value.

Soo..... thats quite a bit of data to handle right... Nope, not at all. If you automatize it correctly :)

What i do on the Phone:

Because i'm a lazy bum i've scripted all these copy steps into a single one touch Solution.

I simply press Start Script, and done :) Go on Benchmarking for as long as i like, and then use the Stop script.

Start Script:

#!/system/bin/sh
cat /sys/devices/system/cpu/cpu0/cpufreq/stats/time_in_state > /sdcard/Download/Stats/time_in_state_$(date "+%Y%m%d_%H%M")_small_start
cat /sys/devices/system/cpu/cpu1/cpufreq/stats/time_in_state > /sdcard/Download/Stats/time_in_state_$(date "+%Y%m%d_%H%M")_small1_start
cat /sys/devices/system/cpu/cpu2/cpufreq/stats/time_in_state > /sdcard/Download/Stats/time_in_state_$(date "+%Y%m%d_%H%M")_big_start
cat /sys/devices/system/cpu/cpu3/cpufreq/stats/time_in_state > /sdcard/Download/Stats/time_in_state_$(date "+%Y%m%d_%H%M")_big3_start
cat /sys/devices/system/cpu/cpu0/cpufreq/stats/total_trans > /sdcard/Download/Stats/trans_stat_$(date "+%Y%m%d_%H%M")_start
cat /sys/devices/system/cpu/cpu1/cpufreq/stats/total_trans >> /sdcard/Download/Stats/trans_stat_$(date "+%Y%m%d_%H%M")_start
cat /sys/devices/system/cpu/cpu2/cpufreq/stats/total_trans >> /sdcard/Download/Stats/trans_stat_$(date "+%Y%m%d_%H%M")_start
cat /sys/devices/system/cpu/cpu3/cpufreq/stats/total_trans >> /sdcard/Download/Stats/trans_stat_$(date "+%Y%m%d_%H%M")_start
cat /sys/class/power_supply/battery/capacity >> /sdcard/Download/Stats/trans_stat_$(date "+%Y%m%d_%H%M")_start
cat /sys/class/power_supply/battery/temp >> /sdcard/Download/Stats/trans_stat_$(date "+%Y%m%d_%H%M")_start
cat /sys/devices/soc/b00000.qcom,kgsl-3d0/devfreq/b00000.qcom,kgsl-3d0/trans_stat > /sdcard/Download/Stats/GPU_trans_stat_$(date "+%Y%m%d_%H%M")_start

If you're wondering about the Big1 and Small3 ... that's because maybe for some reason Core 0 and Core 1 which are both small cores in the same cluster which uses the same Frequency do not use the same frequency. Just a Backup, it's not used in the later Excel file.

There are also 2 lines for Battery Statistics, registring the Battery % and Battery Temperature at the time of the scripts execution. I'd rather have a Time every X period but i'm not yet finished scrapping the dumpsys batterystats for that.... maybe on a later date.

Stop Script:

#!/system/bin/sh
cat /sys/devices/system/cpu/cpu0/cpufreq/stats/time_in_state > /sdcard/Download/Stats/time_in_state_$(date "+%Y%m%d_%H%M")_small_end
cat /sys/devices/system/cpu/cpu1/cpufreq/stats/time_in_state > /sdcard/Download/Stats/time_in_state_$(date "+%Y%m%d_%H%M")_small1_end
cat /sys/devices/system/cpu/cpu2/cpufreq/stats/time_in_state > /sdcard/Download/Stats/time_in_state_$(date "+%Y%m%d_%H%M")_big_end
cat /sys/devices/system/cpu/cpu3/cpufreq/stats/time_in_state > /sdcard/Download/Stats/time_in_state_$(date "+%Y%m%d_%H%M")_big3_end
cat /sys/devices/system/cpu/cpu0/cpufreq/stats/total_trans > /sdcard/Download/Stats/trans_stat_$(date "+%Y%m%d_%H%M")_end
cat /sys/devices/system/cpu/cpu1/cpufreq/stats/total_trans >> /sdcard/Download/Stats/trans_stat_$(date "+%Y%m%d_%H%M")_end
cat /sys/devices/system/cpu/cpu2/cpufreq/stats/total_trans >> /sdcard/Download/Stats/trans_stat_$(date "+%Y%m%d_%H%M")_end
cat /sys/devices/system/cpu/cpu3/cpufreq/stats/total_trans >> /sdcard/Download/Stats/trans_stat_$(date "+%Y%m%d_%H%M")_end
cat /sys/class/power_supply/battery/capacity >> /sdcard/Download/Stats/trans_stat_$(date "+%Y%m%d_%H%M")_end
cat /sys/class/power_supply/battery/temp >> /sdcard/Download/Stats/trans_stat_$(date "+%Y%m%d_%H%M")_end
cat /sys/devices/soc/b00000.qcom,kgsl-3d0/devfreq/b00000.qcom,kgsl-3d0/trans_stat > /sdcard/Download/Stats/GPU_trans_stat_$(date "+%Y%m%d_%H%M")_end

So yeah, you see it reads the exact same files, just saves it in a different location.

P.S Script might fail if you don't have a "Stats" folder in your downloads folder. Or if you're using Android 6.0 and cannot access /sdcard/ and need to use /storage/emulated/0/ or a different path.

Copy all these files from Phone to your computer and continue with Excel.

What i do on the Computer:

I start Excel, press the Import button, done.

Seriously. Watch this Video here.

[YOUTUBE]eFVDq1XVfYE[/YOUTUBE]

One click and you get the Graphs working as is, with statistics for CPU & Transitions, GPU & Transitions, Battery drain (also Per Hour) and Battery Temperature at start and at end.

I've added the Excel Template in the attachements below. But as we all know... you do NOT download an Excel file with Macros from the internet... you simply don't! i've added the file as .xlsx without macros. You can find the whole vbs script code righ here in the spoiler.

Sub ImportALL()
Sheets("Import").Select
Range("C2").Select
sPath = ActiveCell.Value
Range("C3").Select
sStart = ActiveCell.Value
Range("C4").Select
sEnd = ActiveCell.Value

Sheets("Big Start").Select
With ActiveSheet.QueryTables.Add(Connection:= _
"TEXT;" & sPath & "\time_in_state_" & sStart & "_big_start." _
, Destination:=Range("$B$1"))
.Name = "time_in_state_big_start._1"
.FieldNames = True
.RowNumbers = False
.FillAdjacentFormulas = False
.PreserveFormatting = True
.RefreshOnFileOpen = False
.RefreshStyle = xlOverwriteCells
.SavePassword = False
.SaveData = True
.AdjustColumnWidth = True
.RefreshPeriod = 0
.TextFilePromptOnRefresh = False
.TextFilePlatform = 437
.TextFileStartRow = 1
.TextFileParseType = xlDelimited
.TextFileTextQualifier = xlTextQualifierDoubleQuote
.TextFileConsecutiveDelimiter = True
.TextFileTabDelimiter = True
.TextFileSemicolonDelimiter = False
.TextFileCommaDelimiter = False
.TextFileSpaceDelimiter = True
.TextFileOtherDelimiter = "*"
.TextFileColumnDataTypes = Array(9, 1)
.TextFileTrailingMinusNumbers = True
.Refresh BackgroundQuery:=False
End With

Sheets("Small Start").Select
With ActiveSheet.QueryTables.Add(Connection:= _
"TEXT;" & sPath & "\time_in_state_" & sStart & "_small_start." _
, Destination:=Range("$B$1"))
.Name = "time_in_state_small_start._1"
.FieldNames = True
.RowNumbers = False
.FillAdjacentFormulas = False
.PreserveFormatting = True
.RefreshOnFileOpen = False
.RefreshStyle = xlOverwriteCells
.SavePassword = False
.SaveData = True
.AdjustColumnWidth = True
.RefreshPeriod = 0
.TextFilePromptOnRefresh = False
.TextFilePlatform = 437
.TextFileStartRow = 1
.TextFileParseType = xlDelimited
.TextFileTextQualifier = xlTextQualifierDoubleQuote
.TextFileConsecutiveDelimiter = True
.TextFileTabDelimiter = True
.TextFileSemicolonDelimiter = False
.TextFileCommaDelimiter = False
.TextFileSpaceDelimiter = True
.TextFileOtherDelimiter = "*"
.TextFileColumnDataTypes = Array(9, 1)
.TextFileTrailingMinusNumbers = True
.Refresh BackgroundQuery:=False
End With

Sheets("big end").Select
With ActiveSheet.QueryTables.Add(Connection:= _
"TEXT;" & sPath & "\time_in_state_" & sEnd & "_big_end." _
, Destination:=Range("$B$1"))
.Name = "time_in_state_big_end._1"
.FieldNames = True
.RowNumbers = False
.FillAdjacentFormulas = False
.PreserveFormatting = True
.RefreshOnFileOpen = False
.RefreshStyle = xlOverwriteCells
.SavePassword = False
.SaveData = True
.AdjustColumnWidth = True
.RefreshPeriod = 0
.TextFilePromptOnRefresh = False
.TextFilePlatform = 437
.TextFileStartRow = 1
.TextFileParseType = xlDelimited
.TextFileTextQualifier = xlTextQualifierDoubleQuote
.TextFileConsecutiveDelimiter = True
.TextFileTabDelimiter = True
.TextFileSemicolonDelimiter = False
.TextFileCommaDelimiter = False
.TextFileSpaceDelimiter = True
.TextFileOtherDelimiter = "*"
.TextFileColumnDataTypes = Array(9, 1)
.TextFileTrailingMinusNumbers = True
.Refresh BackgroundQuery:=False
End With

Sheets("small end").Select
With ActiveSheet.QueryTables.Add(Connection:= _
"TEXT;" & sPath & "\time_in_state_" & sEnd & "_small_end." _
, Destination:=Range("$B$1"))
.Name = "time_in_state_small_end._1"
.FieldNames = True
.RowNumbers = False
.FillAdjacentFormulas = False
.PreserveFormatting = True
.RefreshOnFileOpen = False
.RefreshStyle = xlOverwriteCells
.SavePassword = False
.SaveData = True
.AdjustColumnWidth = True
.RefreshPeriod = 0
.TextFilePromptOnRefresh = False
.TextFilePlatform = 437
.TextFileStartRow = 1
.TextFileParseType = xlDelimited
.TextFileTextQualifier = xlTextQualifierDoubleQuote
.TextFileConsecutiveDelimiter = True
.TextFileTabDelimiter = True
.TextFileSemicolonDelimiter = False
.TextFileCommaDelimiter = False
.TextFileSpaceDelimiter = True
.TextFileOtherDelimiter = "*"
.TextFileColumnDataTypes = Array(9, 1)
.TextFileTrailingMinusNumbers = True
.Refresh BackgroundQuery:=False
End With

Sheets("GPU Trans Start").Select
With ActiveSheet.QueryTables.Add(Connection:= _
"TEXT;" & sPath & "\GPU_trans_stat_" & sStart & "_start." _
, Destination:=Range("$B$1"))
.Name = "trans_stat_start._1"
.FieldNames = True
.RowNumbers = False
.FillAdjacentFormulas = False
.PreserveFormatting = True
.RefreshOnFileOpen = False
.RefreshStyle = xlOverwriteCells
.SavePassword = False
.SaveData = True
.AdjustColumnWidth = True
.RefreshPeriod = 0
.TextFilePromptOnRefresh = False
.TextFilePlatform = 437
.TextFileStartRow = 1
.TextFileParseType = xlDelimited
.TextFileTextQualifier = xlTextQualifierDoubleQuote
.TextFileConsecutiveDelimiter = True
.TextFileTabDelimiter = True
.TextFileSemicolonDelimiter = False
.TextFileCommaDelimiter = False
.TextFileSpaceDelimiter = True
.TextFileOtherDelimiter = "*"
.TextFileColumnDataTypes = Array(9, 1)
.TextFileTrailingMinusNumbers = True
.Refresh BackgroundQuery:=False
End With

Sheets("GPU Trans End").Select
With ActiveSheet.QueryTables.Add(Connection:= _
"TEXT;" & sPath & "\GPU_trans_stat_" & sEnd & "_end." _
, Destination:=Range("$B$1"))
.Name = "trans_stat_end._1"
.FieldNames = True
.RowNumbers = False
.FillAdjacentFormulas = False
.PreserveFormatting = True
.RefreshOnFileOpen = False
.RefreshStyle = xlOverwriteCells
.SavePassword = False
.SaveData = True
.AdjustColumnWidth = True
.RefreshPeriod = 0
.TextFilePromptOnRefresh = False
.TextFilePlatform = 437
.TextFileStartRow = 1
.TextFileParseType = xlDelimited
.TextFileTextQualifier = xlTextQualifierDoubleQuote
.TextFileConsecutiveDelimiter = True
.TextFileTabDelimiter = True
.TextFileSemicolonDelimiter = False
.TextFileCommaDelimiter = False
.TextFileSpaceDelimiter = True
.TextFileOtherDelimiter = "*"
.TextFileColumnDataTypes = Array(9, 1)
.TextFileTrailingMinusNumbers = True
.Refresh BackgroundQuery:=False
End With
Sheets("Trans Stat").Select
With ActiveSheet.QueryTables.Add(Connection:= _
"TEXT;" & sPath & "\trans_stat_" & sStart & "_start." _
, Destination:=Range("$B$2"))
.Name = "trans_stat_start._1"
.FieldNames = True
.RowNumbers = False
.FillAdjacentFormulas = False
.PreserveFormatting = True
.RefreshOnFileOpen = False
.RefreshStyle = xlInsertDeleteCells
.SavePassword = False
.SaveData = True
.AdjustColumnWidth = True
.RefreshPeriod = 0
.TextFilePromptOnRefresh = False
.TextFilePlatform = 437
.TextFileStartRow = 1
.TextFileParseType = xlDelimited
.TextFileTextQualifier = xlTextQualifierDoubleQuote
.TextFileConsecutiveDelimiter = False
.TextFileTabDelimiter = True
.TextFileSemicolonDelimiter = False
.TextFileCommaDelimiter = False
.TextFileSpaceDelimiter = False
.TextFileColumnDataTypes = Array(1)
.TextFileTrailingMinusNumbers = True
.Refresh BackgroundQuery:=False
End With
With ActiveSheet.QueryTables.Add(Connection:= _
"TEXT;" & sPath & "\trans_stat_" & sEnd & "_end." _
, Destination:=Range("$C$2"))
.Name = "trans_stat_end._1"
.FieldNames = True
.RowNumbers = False
.FillAdjacentFormulas = False
.PreserveFormatting = True
.RefreshOnFileOpen = False
.RefreshStyle = xlInsertDeleteCells
.SavePassword = False
.SaveData = True
.AdjustColumnWidth = True
.RefreshPeriod = 0
.TextFilePromptOnRefresh = False
.TextFilePlatform = 437
.TextFileStartRow = 1
.TextFileParseType = xlDelimited
.TextFileTextQualifier = xlTextQualifierDoubleQuote
.TextFileConsecutiveDelimiter = False
.TextFileTabDelimiter = True
.TextFileSemicolonDelimiter = False
.TextFileCommaDelimiter = False
.TextFileSpaceDelimiter = False
.TextFileColumnDataTypes = Array(1)
.TextFileTrailingMinusNumbers = True
.Refresh BackgroundQuery:=False
End With

Sheets("Graph").Select
End Sub

Most of that Stuff is a recorded Macro and adjusted to my needs, i'm not really a pro at excel or vbs scripting^^ But hey, it works.

The Result:

General Stats:

Time	30,1 Minutes

Battery Used	7%

% per Hour	14,0

Temp Started	31,5°C

Temp Ended	31,2°C

CPU Time in State:

GPU Transitions in Numbers:

As Graph:

GPU Time in State:

Benchmarking Best Practices:

You can now run your Antutu, prefered Game or whatever. But just a few things you should keep in mind while Benchmarking.

Automatic Brightness causes different Batterydrain/heat. Use Manual instead, if possible lowest as Screen itself uses quite a bit of battery. Read this

Use Flight mode if you don't need internet. Mobile Network or WiFi cause irregular Batterydrain.

Expect Thermal Throttling. Take a good look at the first Graph here.... It takes roughly 40 Minutes on full power for a HTC10 to stop increasing battery temperatur rapidly. You will probably never reach over 45°C Battery Temperature with normal usage, but make sure to take thermal throttling into account. When i do a 10 Minute Benchmark i run 10 minutes without recording in advance to heat up the phone.

Watch out for Boost functions, InputBoost, Touchboost, PnP Manager applaunch Boost and others. Be Aware that they might interfere with what you're planing to find out.

For Governor Benchmarking i prefer to simulate a "Normal daily activity" by using the app Repetitiouch. You can create a custom pattern and repeat it infinitley. Something like this. Currently i use TugaBrowser, HTC Mail, Whatsapp and Tapatalk. As these are the apps i mostly use during my daily life.

Another pretty neat app is DiscoMark. This app Opens and Closes Apps you select and measures starting time. But this is not purely CPU based but also Storage dependant.

Happy benchmarking :)