天天看点

(转载)测试工具monkey

转自http://www.418log.org/post-32.html

1)进入shell

 在桌面点开始--运行 输入cmd 点确定 或打开 cmd.exe 进入sdk tools目录如:

<code>1</code>

<code>C:\Users\Administrator&gt;d:</code>

<code>2</code>

<code>C:\Users\Administrator&gt;cd D:\Program Files\android-sdk\platform-tools&gt;</code>

 查看本机已经启动的模拟器

<code>D:\Program Files\android-sdk\platform-tools&gt;adb devices</code>

<code>List of devices attached</code>

<code>3</code>

<code>emulator-</code><code>5554</code>   <code>device</code>

 进入shell命令行

 adb shell

 后显示为#  如果显示为$   输入su

 exit 退出

 在 adb shell 命令前运行 adb remount

(2)进入shell后

 ls

 cd data

 下面还有个data,进入后下面是程序的包

 可以直接输入monkey -p com.jd.customer -v 50,后会自动切换界面

 也可以退出shell,在命令行输入,

 adb shell  monkey -p com.jd.customer -v 50 --hprof 生成报告

 .hprof 文件会自动保存在SD卡上,然后把.hprof 文件拷贝到PC上的

  \ android-sdk-windows\tools目录下。

  这个由DDMS生成的文件不能直接在MAT打开,需要转换。运行cmd打开命令行,

  cd到\ android-sdk-windows\tools所在目录,并输入命令

  hprof-conv xxxxx.hprof yyyyy.hprof,其中xxxxx.hprof为原始文件,

  yyyyy.hprof为转换过后的文件。

  转换过后的文件自动放在android-sdk-windows\tools 目录下。

  OK,到此为止,.hprof文件处理完毕,可以用来分析内存泄露情况了。