android studio2.4,Android Profiler in Android Studio 2.4 preview

The newAndroid Profilerwindow in the Android Studio 2.4 preview replaces theAndroid Monitor. The advanced profiling tools display realtime data updates for CPU, memory, and network activity.

The default view in theAndroid Profilerwindow, as shown in figure 1, displays a simplified set of data for each profiler. You must first select(1)the device and(2)the app process you want to profile. You can then click one of the graphs to see the more detailed timeline. Every view also includes(3)timeline zoom controls,(4)a button to jump to the realtime data, and an(5)event timeline that shows the lifecycle of activities and see all input events and screen rotation events.

8080569d9096e082ae6def7e5fa5c120.png

Figure 1. The Android Profiler overview, showing the timeline for all profilers

CPU Profiler

The CPU Profiler shows realtime CPU usage for your app process and system-wide CPU usage on a timeline.

You can select between(1)a traditional instrumented trace (method traces) and a sample-based trace. Then click(2) Recordto begin tracing your code. Once you're done recording, the timeline indicates(3)the captured region, you can(4)view the state of each thread,and(5)see either a top-down list, bottom-up list, or flame chart for the methods that have executed during the recording.

d7c591ea3a374a6ba2e92c4f5695fd28.png

Figure 2. The CPU Profiler, with results from sampled method tracing

Memory Profiler

The Memory Profiler view combines the features from Heap Viewer, Allocation Tracker, and Memory Monitor, so you can view realtime count of allocated objects and garbage collection events on a timeline, capture heap dumps, and record memory allocations, all from one interface.

The Memory Profiler shows the amount of memory used by your app on a timeline, according to the memory size on the left y-axis. Each memory type (such as Java, Native, and Graphics) is indicated with a different color in a stacked graph. The total number of objects allocated by your app is indicated with a dotted line, according to the y-axis on the right. Values for each are also specified in a key at the top of the graph.

The toolbar at the top of the window allows you to(1)Force garbage collection, (2) Capture a heap dump, and(3)Record memory allocations.

945f78eac7fba0ae935927b4dae5c4be.png

Figure 3.The Memory Profiler, with results from a memory allocation recording

When you capture a heap dump or record memory allocations, the(4)recording event is indicated on the timeline. Your results then appear in(5)the pane below the timeline. In figure 2, this window shows the memory allocation results during the time indicated in the timeline. When viewing either a heap dump or memory allocations, you can select a class name from this list to view the(6)list of instances on the right. Clicking an instance there, reveals(7)a third pane below, showing either the stack trace for where that memory was allocated (when viewing the allocation record), or the remaining references to that object (when viewing a heap dump).

You can also capture a heap dump while memory allocation tracking is turned on to get stack traces in the heap dump (for objects allocated after allocation was turned on).

Network Profiler

The Network Profiler displays realtime network activity on a timeline, showing data sent and received, as well as the current number of connections. At the top of the window, you can see the event timeline and(1)radio power state (high/low) vs Wi-Fi.

On the timeline, you can(2)click and drag to select a portion of the timeline to inspect the traffic. The(3)window below then shows files sent and received during the selected portion of the timeline, including file name, size, type, status, and time. You can sort this list by clicking any of the column headers. You also see a detailed breakdown of the selected portion of the timeline, showing when each file was sent or received.

Click a file name to view(4)detailed information about a selected file sent or received. Click the tabs to view the response data, header information, or the call stack.

992051c75cf912fe8424a4d3a22aa611.png

Figure 4.The Network Profiler, showing a network request and response

Network Connection Troubleshooting

If the Network Profiler detects traffic values, but cannot identify any supported network requests, you will receive the following error message:

“No connections supported for instrumentation.”

Currently, the Network Profiler only supports theHttpURLConnectionlibrary for network connections. If your app uses another network connection library, you will not be able to view your network activity in the Network Profiler. If you have received this error message, but your appdoesuseHttpURLConnection, pleasereport a bugso we can investigate the issue.

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值