How to get higher precision of CPU% than that from TOP command?
You didn't mention it in your post, but in the comment you said that you really need CPU utilization per thread, not per process.
If you can't find a tool that's accurate enough, you can look directly in /proc/[pid]/task/[ThreadName]
as described in the man page for /proc
. This gives total CPU time consumed in "clock ticks" since execution began. Getting better resolution than this is probably difficult or impossible.
Edit
From the OP's comment, a command that lists the relevant information is:
adb shell cat /proc/${pid}/task/*/stat | awk -F\ '{print $1, $14}'
This just cat
s the correct /proc
files to the debugging host, which runs a tiny awk
program to print the columns for pid
and user time
. You could also easily use cut -d " " -f1,14
or something similar in perl
to get the columns if awk
isn't available.
TOP command vs dumpsys cpuinfo: Which one is more accurate?
I suggest going with dumpsys. In my experience, TOP gets its information from a variety of sources, some direct and some estimates. The estimates were necessary in earlier architectures because there weren't any means to directly measure certain statistics. Now days, many of these measurements are available from the lowest level. The main problem with TOP is figuring out if it has been updated to obtaining these measurements directly or is it still estimating them.
In contrast, dumpsys gets its info from /proc. These measurements are at the lowest level or very nearly so. As such, as the architecture changes, /proc is more likely to be updated.
The second part of your question brings up one of /proc's deficiencies. /proc is generally very poorly documented, including sampling rates, etc. I haven't seen a case where a sampling rate for /proc (and so dumpsys) could be set, but that doesn't mean such capability doesn't exist. (Often, the sampling rate is actually dumped along with the data.)
How do you use top to extract only the CPU usage and the process names (command) columns?
From the command line or from within top
?
If you're already in top
, press f and toggle the columns you want to see.
Alternatively, you can use ps
:
ps -eo %cpu,pid --sort -%cpu
Related Topics
What Kind of Font Files Do I Need for Modern Browsers, Android and iOS
Making a Triangle Shape Using Xml Definitions
Sharing Data Between Fragments Using New Architecture Component Viewmodel
Audiorecord Object Not Initializing
How to Strip or Escape HTML Tags in Android
How to Create a Signed APK File Using Cordova Command Line Interface
Implement Page Curl on Android
Deleting Android Sms Programmatically
Share Sqlite Database Between 2 Android Apps
Passing Data from Java Class to Web View HTML
Error: No Resource Identifier Found for Attribute 'Adsize' in Package 'Com.Google.Example' Main.Xml
Android - Local Image in Webview
Unexpected Value from Nativegetenabledtags: 0
Calling Startactivity() from Outside of an Activity
"Native Typeface Cannot Be Made" Only for Some People
What Are My Options for Storing Data When Using React Native? (iOS and Android)
How to Interface with the Badgeprovider on Samsung Phones to Add a Count to the App Icon