Monitor Activities of iOS Apps Using Xcode Instruments

Download Monitor Activities of iOS Apps Using Xcode Instruments

Post on 22-Jan-2018




2 download

Embed Size (px)


<ol><li> 1. Monitor Activities of iOS Apps Using Xcode Instruments When we are taking a shot at iOS application, we are thinking of new features for making our app great. Apart from improving / enhancing our app, we ought to instrument its code also. The Instrument allows you to check your code for performance issues, memory issues, reference cycles, and other problems. With the help of these instruments, we can bug-free potential applications as best as possible. Xcode incorporates a performance tuning application named Instruments that monitor your apps network and file I/O activity. Lets investigate it one-by-one and its usage: 1. Activity Monitor Activity Monitor is an awesome utility to monitor what type of applications and services are chewing up CPU cycles, energy hogs, and other things that might slow your Mac down. Using activity monitor one can figure out why iPhone was chewing the battery when comes in sleeping mode. When Instruments comes in a sleeping mode, One can easily monitor devices and its processes. 2. Allocations The Allocations instrument captures information about memory allocation for an app. You can inspect that everything is in sequence or not. If you happen to be </li><li> 2. working on Swift, all of your Swift objects will get prefixed with the application name. If you are working on Objective-C, it's a little bit difficult to find, essentially have to know the names of the things you are looking for. If you happen to have prefixed your files you can search on that prefix and see all your objects that way, or you can seek on some naming scheme you might have used. If you click on the little arrow next to the object, itll show you all the allocations of that object, and who is responsible for creating it. Then, if you click on the little arrow next to one of those allocations, you can see the detailed information about its retain and release count. If that number doesnt reach 0, it wont get deallocated. 3. Leaks It includes Allocation and Leak templates that will help you see all the memory allocations and potential leaks that are happening. You cannot get an excessive amount of detail on the Leaks panel, but it will take snapshots for you, at specified intervals, to see if you have any memory that has been allocated yet not able to deallocate. This often happens in the case of Objective-C and using some of the C libraries where you are responsible for releasing any allocated memory. If you are working on Swift, these leaks are less common as it takes care of some of the things you used to do with Objective-C. 4. Timer Profiler At the time of running your application, sometimes you can be delayed in performing some task. If you want to examine that, the Timer Profiler instrument is very beneficial. It will be more effective, how to make your apps faster, more efficient and can be used to identify problems and verify your fixes. It is easy to improve your app's power usage and performance. 5. Energy Log It monitors factors that influence energy usage on an iOS ipad application developers device, including CPU activity, network activity, screen brightness, and more. Keep note that this tool doesnt supports in simulator. It gathers data from your running app and presents it in a graphical timeline. Identify the areas where usage is highest, and see if you can reduce impact in those areas.The Energy Usage instrument indicates a level from 0 to 20, indicating how much energy your app is using at any given time. 6. Network Connection The Connection instrument captures information about TCP/IP and UDP/IP networks activating over time. Like Energy Log, this tool also doesnt support in </li><li> 3. simulator. The timeline pane displays graphs that represent the amount of network activity in the following categories: Wi-Fi Packets (in) Wi-Fi Packets (out) Cell Packets (in) Cell Packets (out) 7. System Trace This template provides comprehensive information about system behaviour. It shows when threads are scheduled, and shows thread transitions from user to system code via system calls and memory operations. This template may be used with OS X or iOS. It includes: System Load Thread State Trace Virtual Memory Trace Points of Interest System Call Trace 8. OpenGL ES Analyzer The OpenGL ES Analyzer instrument captures information about OpenGL ES activity. It detects problems and offer solutions based on best practices and knowledge of Apples hardware and software platforms. Again, this tool also doesnt supports in simulator. It displays following trace details: The sequence number of the event. Context Thread Trace 9. System Usage This template monitors an app and records system I/O activity related to files, sockets, and shared memory. This includes inputs, outputs, duration, backtrace, call tree, and more for each call. This template may be used with iOS only. I/O Activity The I/O Activity instrument captures information about I/O events. It displays: Sequence for number of events . Duration </li><li> 4. In File In Bytes Out File Out Bytes Thread ID Stack Depth Error Path Parameters 10. GPU Driver Monitors GPU hardware activity. This Instrument monitors GPU-side events. Keep note that this tool doesnt support in simulator. The following GPU activity columns are available in the detail pane. An event within your processing pipeline. This can be a Vertex, Fragment, or Compute processing phase. The state of the event. This can be Busy or Idle. The start time of the event. The end time of the event. The duration of the event. Additional notes about the event 11. Zombies This template measures general memory usage of an app, focusing on the detection of over-released objects, known as zombies. It provides statistics on object allocations by class, as well as memory address histories for active allocations. This template may be used with OS X or iOS. 12. Core Animation This template uses time profiling to measure graphics performance and CPU usage in an app. This template may be used with iOS only. This tool doesnt support in simulator. The Core Animation instrument captures information on selected animation statistics. You may see spikes in the timeline pane where the frame rate of the app becomes significantly better. In some cases, however, spikes can be caused by changing the device between landscape and normal orientationand if you dont know this, you might spend time trying to find what caused the performance increase. 13. Automation It is a powerful tool you can use to collect data about the performance and behaviour of one or more processes on the system. </li><li> 5. Lets gather disparate types of data and view them side by side the automation instrument works from scripts (written in JavaScript). It simulates/fires required events on target Application. Test script must be a valid executable JavaScript file accessible to the instrument on the host computer. 14. Core Data The Core Data Fetches instrument that captures information about data store fetch operations performed by Core Data applications. It can record information from a single process or all processes. The all-processes option records information only from running Core Data applications. You can export recorded information to a DTrace script. This tool doesnt support in simulator. The timeline pane displays the following information, based on the instruments configuration: Fetch count Thread ID (tid) Stack Depth Fetch duration It also records the information regarding: Core data saves Core data fetches Core Data Cache Misses 15. File Activity In file activity, It captures information about file open, close, and start operations. In read/ write, it captures information from reads and writes to files. This includes the read, write, pread, and pwrite functions. This instrument uses DTrace in its implementation and can be exported to a DTrace script. Keep note that this tool doesnt support in simulator. In File Attributes, it captures information about changes to ownership and access permissions for files. You can export recorded information to a DTrace script. In Directory I/O, it captures information about directory operations, specifically the delete, link, mkdir, mount, rename, rmdir, symlink, unlink, and unmount functions. 16. Counters The Counters instrument records information from user-managed PM (Performance Monitor) events. Keep note that this tool doesnt support in simulator. 17. Cocoa Layout The Cocoa Layout instrument captures information on changes to NSLayoutConstraint objects. Keep note that this tool doesnt support in simulator. </li><li> 6. 18. Metal Application Records Metal application events. It displays a graph indicating Metal application events. This article demonstrated the instrument tools in Xcode. Although its embedded within and may be used with Xcode, Instrument is a separate app, which may be used independently as needed. Incorporating Instruments into your workflow from the beginning of the app development process can save you time later by helping you find issues early in the development cycle. Once you become more comfortable with the tooling, youll end up using it more, and the better your code will become. Youll become more proactive about checking on things that you know might cause an issue and itll become part of your standard workflow. Hopefully, all of this will help you track down and fix those memory leaks. The best iOS application developers in India are using these tools to check application usage, performance of app, memory leak, etc based on application usage, requirement and use-cases. Happy Healthy Coding !!! </li></ol>