Forums - How to shell script Trepn?

12 posts / 0 new
Last post
How to shell script Trepn?
ugupta
Join Date: 30 Apr 14
Posts: 6
Posted: Mon, 2014-05-05 11:37

Hi,

I need to profile a benchmark without intracting with the GUI. Can I use Trepn in a shell script? More precisely I just want to start and stop profiling from the shell.

Thanks,
Ujjwal

  • Up1
  • Down0
TrepnEng
Profile picture
Join Date: 31 Jan 13
Posts: 60
Posted: Mon, 2014-05-05 14:15

Hi Ujjwal,

Yes, you can use Trepn Profiler in a shell script. To do that, you'll need to use Android intents to control Trepn via adb shell broadcasts.You can find an example on how to do that in section 3.2.1 of the Trepn 5.0 User Guide on page 38. The example in the user guide shows how you can start profiling, stop profiling, and load preferences. Although the examples specifically mention .bat files, the same commands work in bash, csh, or other scripts.

To start with, I'd recommend trying the following commands in your script:

adb shell am startservice --user 0 com.quicinc.trepn/.TrepnService
ping 123.45.67.89 -n 1 -w 1000 > NUL
adb shell am broadcast -a com.quicinc.trepn.start_profiling

This set of commands launches Trepn (if it's not running already) and starts profiling with the currently selected set of preferences. The "ping 123.45.67.89 -n 1 -w 1000 > NUL" command creates a one second delay. This command needs to be executed after launching Trepn but before sending the start profiling command. This gives Android enough time to launch Trepn prior to sending the start profiling command. Please note that this command may be different if you're using Linux or Mac.

Please let me know if you run into any problems using Android intents to control Trepn and we'll be happy to help.

- Eugene

 

  • Up2
  • Down0
ugupta
Join Date: 30 Apr 14
Posts: 6
Posted: Thu, 2014-05-08 10:56

Thanks Eugene! I have not been able to get onto this since I am soing soemthing else right now. But I will post a bash script in this thread once I work it out.

  • Up0
  • Down0
Ranjith
Profile picture
Join Date: 12 Mar 15
Location: Bangalore
Posts: 2
Posted: Thu, 2015-03-26 02:39

Could you please provide me the link to the section 3.2.1 of the Trepn 5.0 User Guide on page 38

  • Up0
  • Down0
ToolsPM
Join Date: 15 Feb 13
Posts: 393
Posted: Thu, 2015-03-26 07:45

We don't have a way to directly link to that section, however, you can download the Zip file that contains the User Guide herehttps://developer.qualcomm.com/download/trepn-profiler.zip

I've also attempted to copy and paste the text from that section below, but it might be hard to read because some of the formatting has been lost. 

3.2.1 Commands for sending Intents from an external .bat script
The applicable commands for sending Intents from an external .bat script are:
 
 To start Trepn Profiler:
adb shell am startservice com.quicinc.trepn/.TrepnService
A Trepn Profiler icon displays in the Android notification area if TrepnService is running.
If the command does not start the Trepn Profiler service, it may be necessary to include the “--user 0” argument within the startservice command or to issue an “adb root” command first.
 
 To start profiling:
adb shell am broadcast –a com.quicinc.trepn.start_profiling
In this code, if Storage Mode is set to Database in General preferences, the run is given a default name. If Storage Mode is not set to Database, the run will not be saved.
 
 It is possible to choose a name to give to the run when starting profiling. To start profiling with a chosen name:
adb shell am broadcast –a com.quicinc.trepn.start_profiling –e com.quicinc.trepn.database_file “<string_value>”
In this command, change <string_value> to the name you would like to give to the run. The run can be accessed by pressing Analyze Run from the Trepn Profiler main menu screen.
 
 To stop profiling:
adb shell am broadcast –a com.quicinc.trepn.stop_profiling
 
 To load preferences:
adb shell am broadcast -a com.quicinc.trepn.load_preferences –e com.quicinc.trepn.load_preferences_file “<string_value>”
In this code, change <string_value> to the path of the preferences file on the device you would like to load. The default location for preferences is /sdcard/trepn/saved_preferences. The Intent to load preferences should be sent before sending the Intent to start profiling.

 

- Rick

  • Up0
  • Down0
Ranjith
Profile picture
Join Date: 12 Mar 15
Location: Bangalore
Posts: 2
Posted: Thu, 2015-03-26 21:20

Thank you Rick!!

  • Up0
  • Down0
roshanbharathdas
Join Date: 2 Oct 16
Posts: 8
Posted: Sun, 2016-10-02 09:53

Hello,

I am not able to save the profiling as a db file using the below command.

adb shell am broadcast –a com.quicinc.trepn.start_profiling –e com.quicinc.trepn.database_file “<string_value>”

I am using Nexus 6P and profiler 6.2.

The below command starts the profiling in my case:

adb shell am broadcast –a com.quicinc.trepn.start_profiling

It would be great if you can help.

Thanks

  • Up0
  • Down0
--LR
Join Date: 4 May 16
Posts: 20
Posted: Sun, 2016-10-02 22:35

Hi roshanbharathdas,

In the command that you posted, the hyphen characters and quotation marks are not properly encoded. This is a common problem when commands have been copy-and-pasted into the command-line from another source.

Try this command, which has been corrected:

adb shell am broadcast -a com.quicinc.trepn.start_profiling -e com.quicinc.trepn.database_file "test.db"

 

If you experience this problem in the future, then in the command-line, delete and re-type the two hyphen symbols (-a and -e) and the quotation marks, and try again.

 

Let me know if this doesn't resolve your problem.

  • Up0
  • Down0
roshanbharathdas
Join Date: 2 Oct 16
Posts: 8
Posted: Tue, 2016-10-04 09:20

Thank you. It works now. 

  • Up1
  • Down0
ToolsPM
Join Date: 15 Feb 13
Posts: 393
Posted: Tue, 2016-10-04 10:06

Thank you for letting us know it's now working. 

- Rick

  • Up0
  • Down0
thejuskrishna
Join Date: 10 Oct 17
Posts: 1
Posted: Wed, 2017-10-11 00:17

Hi Rick,

I tried running the command - ```adb shell am broadcast –a com.quicinc.trepn.stop_profiling``` to stop the profiling but it actually doesn't. Is there something that I am missing out?

Regards,
Thejus

 

*/
  • Up0
  • Down0
--LR
Join Date: 4 May 16
Posts: 20
Posted: Tue, 2017-11-07 00:32

Hi Thejus,

I know this is a bit late, but I noticed that the command you posted above has an incorrectly encoded hyphen for the "-a" argument.  Perhaps you copy-pasted the command from the Trepn user guide?

Try typing the same command from scratch, or at least deleting and re-typing the hyphen.  In the user guide, the hyphen got encoded incorrectly when it was converted to PDF and it doesn't work in a command-prompt correctly.

adb shell am broadcast -a com.quicinc.trepn.stop_profiling

  • Up1
  • Down0
or Register

Opinions expressed in the content posted here are the personal opinions of the original authors, and do not necessarily reflect those of Qualcomm Incorporated or its subsidiaries (“Qualcomm”). The content is provided for informational purposes only and is not meant to be an endorsement or representation by Qualcomm or any other party. This site may also provide links or references to non-Qualcomm sites and resources. Qualcomm makes no representations, warranties, or other commitments whatsoever about any non-Qualcomm sites or third-party resources that may be referenced, accessible from, or linked to this site.