Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Stop Android(DDMS) Profiler programmatically

does anybody know whether i can stop the profiler from ddms programatically? I have a bit longer process and want to stop the profile after this process is done and not manually. Is there any method to do this?

like image 989
Kani Avatar asked Aug 20 '26 15:08

Kani


1 Answers

If I understand the question correctly you can simply put the following methods in the code of your application:

android.os.Debug.startMethodTracing("name_of_trace");
//here you put what you want to profile
android.os.Debug.stopMethodTracing();

All the traces are stored on /sdcard You can simply use adb pull command to download them:

adb pull /sdcard/name_of_trace.trace

After that you can see the results using command monitor (if you use the old versions of Android tools then you should use traceview command. However, for newer version this command is also working):

monitor name_of_trace.trace
like image 69
Yury Avatar answered Aug 23 '26 00:08

Yury