Android NDK Load CPU

2019-05-30 02:58发布

问题:

Write a program using the Android NDK. The program uses a few libraries. All this is very heavy CPU to 90%. How can I find out which of the libraries of most loads the CPU? is there for this special techniques or tools?

EDIT: That's what I got:



[user@localhost HelloNDK]$ ./remotegdb.sh
Package name is org.divenvrsk.android.hellondk
Found running pid: 7726
Device CPU ABIs: armeabi-v7a armeabi
Using app_out directory: /home/user/Dropbox/HelloNDK/obj/local/armeabi-v7a
68 KB/s (5680 bytes in 0.080s)
Pulled /home/user/Dropbox/HelloNDK/obj/local/armeabi-v7a/app_process from device/emulator.
2206 KB/s (278276 bytes in 0.123s)
Pulled /home/user/Dropbox/HelloNDK/obj/local/armeabi-v7a/libc.so from device/emulator.
Running gdbserver :5039 --attach 7726
su: not found
/home/user/android-ndk-r5b/toolchains/arm-linux-androideabi-4.4.3/prebuilt/linux-x86/bin/arm-linux-androideabi-
/home/user/Dropbox/HelloNDK/libs/armeabi-v7a/gdb.setup
GNU gdb 6.6
Copyright (C) 2006 Free Software Foundation, Inc.
GDB is free software, covered by the GNU General Public License, and you are
welcome to change it and/or distribute copies of it under certain conditions.
Type "show copying" to see the conditions.
There is absolutely no warranty for GDB.  Type "show warranty" for details.
This GDB was configured as "--host=x86_64-linux-gnu --target=arm-elf-linux".
Warning: /home/user/Dropbox/HelloNDK/jni/sox/flac/src/share/include: No such file or directory.
Warning: /home/user/Dropbox/HelloNDK/jni/sox/flac/src/metaflac/include: No such file or directory.
Warning: /home/user/Dropbox/HelloNDK/jni/sox/src/../libpng-1.5.2/include: No such file or directory.
Warning: /home/user/Dropbox/HelloNDK/jni/sox/work/../libpng-1.5.2/include: No such file or directory.
/home/user/Dropbox/HelloNDK/obj/local/armeabi-v7a/gdb.setup:3: Error in sourced command file:
Remote communication error: Connection reset by peer.
(gdb) 

What to do next in order to determine the load certain libraries?

回答1:

ndk-gdb and android-ndk-profiler would help you to get profile information.



回答2:

I propose you to use Intel VTune Amplifier. This profiler allows you to collect hotspots with stacks on Android devices without root or any OS modification. Here is simple guide: http://software.intel.com/en-us/articles/using-intel-vtune-amplifier-on-non-rooted-android-devices