Android:測定

android-measure.png

最適化が必要かどうか、
最適化によって実際に何が改善されたかどうかを判定するためには、
パフォーマンスを計測できなければならない。

時間を測る

時間測定の仕方へgo

重い関数がどこか突き止める★DDMSを使ったMethodProfiling

コード側の準備

Debug.startMethodTracing();
//....測定したい部分
Debug.stopMethodTracing();

いざ★Launch

  1. DDMSビューの「Devices 」,タブにて、プロファイリングしたいアプリプロセスを選択する。
  2. 「Start Method Profiling 」を押す
  3. アプリを好きなように色々操作する
  4. 「Stop Method Profiling」ボタンを押す。
  5. すると、DDMS stops profiling your application で Traceview with the method profiling information を開く。that was collected between the time you clicked on Start Method Profiling and Stop Method Profiling.

Android公式

Graphvizを使って関数ツリーを描く★

dmtracedumpを使えばそんなことができるらしいhttp://developer.android.com/tools/debugging/debugging-tracing.html

メモリの割当過ぎのチェック

DDMS provides a feature to track objects that are being allocated to memory and to see which classes and threads are allocating the objects.
This allows you to track, in real time, where objects are being allocated when you perform certain actions in your application.
This information is valuable for assessing memory usage that can affect application performance.

To track memory allocation of objects:

  • 「Device」タブでトラッキングしたいプロセスを選ぶ
  • Allocation Tracker」タブでStart Trackingボタンを押す。
  • アプリで好きな操作をする
  • Get Allocationsを押す。 to see a list of objects that have been allocated since you clicked on the Start Tracking button. You can click on Get Allocations again to append to the list new objects that that have been allocated.

To stop tracking or to clear the data and start over, click the Stop Tracking button.
Click on a specific row in the list to see more detailed information such as the method and line number of the code that allocated the object.
Tracking memory allocation of objects

ヒープの状態を見る

Viewing heap usage for a process

DDMS allows you to view how much heap memory a process is using. This information is useful in tracking heap usage at a certain point of time during the execution of your application.

To view heap usage for a process:

  • Device」タブでトラッキングしたいプロセスを選ぶ
  • Update Heapボタンを押す
  • Heapタブにて Cause GCを押す。 to invoke garbage collection, which enables the collection of heap data. When the operation completes, you will see a group of object types and the memory that has been allocated for each type. You can click Cause GC again to refresh the data.

Click on an object type in the list to see a bar graph that shows the number of objects allocated for a particular memory size in bytes.

Memory analyzer for Eclipseを使う

hprofのページを見よ


performance

サポートサイト Wikidot.com performance