On Android we can use simpleperf. It's preinstalled on current Android userdebug images, and part of the Android NDK.
simpleperf
userdebug
TODO write me
On desktop Linux we can use perf.
perf