Perf Tool For Mac

  1. Proprietary anvil forging process for long anvil life Removeable and rechargeable trigger-activated LED lighting (Charger included) Variable-speed trigger for speed con.
  2. Comprehensive advice on this topic can be found in the 'Performance' chapter of our book Troubleshooting Mac OS X. Optimizing Mac OS X performance RAM, RAM, and more RAM. Mac OS X loves RAM. Short of buying a new Mac or a processor upgrade, adding RAM is the best way to improve Mac OS X performance.
  3. Novabench is a free tool that provides Mac benchmark test for your whole system, including CPU, RAM and graphics performance. You can test your whole computer in minutes and even compare results with thousands of other systems.

Perforce Software provides enterprise-scale development tools. This includes version control, application lifecycle management, agile planning, and static analysis.

There are several graphical applications and command-line tools available for gathering performance metrics. Some performance tools are installed with Xcode. Others are available for download from the Apple Developer website.

Key Applications

Although Xcode comes with numerous applications for gathering performance data, there are a few that you will use more frequently than others.

Instruments

Instruments combines a set of powerful analysis tools with a graphical user interface to provide unprecedented information about the runtime behavior of your application. Rather than showing only one aspect of your program at a time, you configure each analysis session with one or more instruments, each of which gathers information about a particular performance metric. The data from all instruments is shown side-by-side, making it easier to correlate the data from one instrument to another and detect trends in your application’s behavior.

Among the types of metrics you can gather with the Instruments application are the following:

  • The performance of Core Data–based applications

  • Information about file system reads, writes, and other operations

  • Statistics relating to garbage-collected code

  • Information about graphics operations and performance

  • Statistics about object and other memory-related allocations

  • Information about memory leaks

  • Statistical samples of your application at runtime

  • Information about process-specific and system-level activity

  • Information about Java thread activity

  • Information about events dispatched by Cocoa

For a quick example of how to use Instruments, see Using Instruments. For detailed information, see Instruments User Guide.

Analysis Tools

Instruments is not the only analysis tool that can gather data about the performance of your app. Other analysis tools are geared towards finding specific types of performance problems. Table 3-1 lists the analysis tools installed with Xcode and available for download.

Table 3-1 Analysis tools

Tool

Description

OpenGL Driver Monitor

Gathers GPU-related performance data, including data related to VRAM usage, video bus traffic, and hardware stalls among others. You can use this information to identify the cause of temporary slowdowns or sporadic hesitations in your OpenGL application.

This tool is part of the Graphics Tools for Xcode, available on the downloads page of the Apple Developer website.

OpenGL Profiler

Creates a runtime profile of your OpenGL-based application. You can view function statistics and the call-trace history of your application’s OpenGL calls.

This tool is part of the Graphics Tools for Xcode, available on the downloads page of the Apple Developer website.

heap

Lists all malloc-allocated buffers in the heap of a specified process

This tool is installed in /usr/bin/.

leaks

Searches the memory space of a process for any allocated but unreferenced blocks of memory.

This tool is installed in /usr/bin/.

vmmap

Displays the virtual memory regions allocated to a specified process. You can use this tool to analyze the memory usage of your process.

This tool is installed in /usr/bin/.

Monitoring Tools

Monitoring tools are passive tools that gather data automatically. To use these tools, leave them running while you exercise the features of your program. You can then analyze the data generated by these tools to gain a better understanding of your program’s performance characteristics. Some programs should be left running all the time. Most others can be launched and terminated as needed to gather performance information. Table 3-2 lists the monitoring tools in OS X and available for download.

Table 3-2 Monitoring tools

Tool

Description

Activity Monitor

Displays common usage statistics relating to memory and CPU usage for the currently running processes. You can also initiate the sampling of a process from this application. This tool provides information that is similar to that of the top tool.

This tool is installed in /Applications/Utilities/.

Quartz Debug

Shows screen updates in real time by briefly flashing the areas being redrawn. You can use this tool to analyze your application’s drawing behavior.

This tool is part of the Graphics Tools for Xcode, available on the downloads page of the Apple Developer website.

fs_usage

Displays an ongoing list of file-system activity, as generated by page faults and calls to file-system functions. You can use this tool to understand the file access patterns of your program.

This tool is installed in /usr/bin/.

sc_usage

Displays an ongoing list of system call and page fault statistics.

This tool is installed in /usr/bin/.

top

Displays common system usage statistics relating to memory and CPU usage for the currently running processes. This tool updates the information dynamically so that you can see trends at runtime.

This tool is installed in /usr/bin/.

Hardware Analysis Tools

The CHUD Tools include additional applications for doing hardware and low-level software analysis in OS X. (These tools are not able to analyze hardware running iOS.) Table 3-3 lists the tools that are part of this package, which is available on the downloads page of the Apple Developer website.

Table 3-3 CHUD tools

Name

Description

Reggie SE

Lets you examine and modify CPU and PCI configuration registers.

acid

A command-line tool that analyzes TT6E instruction traces and presents detailed analyses and histograms. You can use this tool to detect bad instruction sequences, such as misaligned operands, data dependency stalls, and spilled loads.

simg4

A command-line tool that is a cycle-accurate simulator of the Motorola 7400 processor. This tool takes TT6 traces as input. (Available in OS X v10.5 and earlier.)

simg5

A command-line tool that is a cycle-accurate simulator of the IBM 970 processor. This tool takes TT6 traces as input. (Available in OS X v10.5 and earlier.)

Additional Command-Line Tools

Table 3-4 lists some additional command-line tools that you can use to monitor and analyze performance in OS X. (These tools are not able to monitor and analyze applications running in iOS.) These tools are located in the /usr/bin/ directory and must be run from a command-line prompt. Most are installed along with the Xcode Tools. For information about these tools, see OS X Man Pages.

Table 3-4 Command-line tools

Name

Description

atos

Converts back and forth between a symbol name and the numeric address of that symbol in a running executable.

c2ph

Displays the C-structures from an object file along with their member offset values.

gprof

Produces execution profiles based on an execution analysis of a program.

malloc_history

Shows the malloc allocations performed by a specified process.

nm

Displays the symbol table information for one or more object files.

otool

Displays the contents of a Mach-O executable in a more human-readable form

pagestuff

Displays information about the logical pages of a Mach-O executable file.

pstruct

Parses the C structures from an object file and displays them along with their member offset values.

sample

Produces an execution profile based on the execution analysis of a program.

vm_stat

Displays Mach virtual memory statistics, including the number of active, inactive, wired, and free pages. This tool also displays page fault and other activity information.



Copyright © 2004, 2013 Apple Inc. All Rights Reserved. Terms of Use | Privacy Policy | Updated: 2013-10-22

-->

This guide explores the key features of the Xamarin Profiler. It look at profilers, profiling and when they should be used, and at a standard workflow for profiling Xamarin applications.

An application’s success depends on the end user experience. As a developer you might have implemented some really awesome features in your app, but if the app is sluggish or full of crashes, the user will likely get rid of it.

Historically, Mono has featured a powerful command-line profiler for gathering information about programs running in the Mono runtime called the Mono log profiler. The Xamarin Profiler a graphical interface for the Mono log profiler, and supports profiling Android, iOS, tvOS, and Mac applications on Mac, and Android, iOS, and tvOS applications on Windows.

The Xamarin Profiler has a number of instruments available for profiling — Allocations, Cycles, and Time Profiler. This guide explores what these instruments measure and how they analyze your application, and clarifies the meaning of the data presented on each screen.

This guide examines common profiling scenarios and introduces the profiler as a tool to help analyze and optimize iOS and Android applications.

Download and Install

Note

You will need to be a Visual Studio Enterprise subscriber to unlock this feature in either Visual Studio Enterprise on Windows or Visual Studio for Mac on a Mac.

The Xamarin Profiler is a standalone application, and is integrated withVisual Studio for Mac and Visual Studio to enable profiling from within the IDE.

Download the install package for your platform:

Once downloaded, launch the installer to add the Xamarin Profiler to your system.

Profilers and Profiling

Profiling is an important and often overlooked step in application development. Profiling is a form of dynamic program analysis - it analyzes the program while it is running and in use. A profiler is a data mining tool that collects information about time complexity, the usage of particular methods, and the memory being allocated. A profiler enables you to drill deep and analyze these metrics to pinpoint problem areas in code.

When designing and developing an application, it is important to not optimize prematurely; that is, spending time developing your code in areas that will rarely be accessed. This is the power of profiling. A profiler provides insight into the most commonly used parts of your code base , and helps locate areas where you should spend time making improvements. Developers should take care to understand where most of the time is spent in your application, and how memory is used by your application.

Profiling is helpful in all types of development, but it is especially crucial in mobile development. Unoptimized code is much more noticeable on mobile platforms than on desktop computers, and the success of your app depends on beautiful and optimized code that runs efficiently.

Xamarin Profiler

The Xamarin Profiler provides developers with a way to profile applications from inside Visual Studio for Mac or Visual Studio. The profiler collects and displays information about the app, which can then be used by the developer to analyze an application’s behavior. There are a number of different ways to profile an application with the Xamarin Profiler, namely memory profiling and statistical sampling. These are carried out through the Allocations and Time Profiler instruments respectively.

Currently, the Xamarin Profiler can be used to test Xamarin.iOS, Xamarin.Android, and Xamarin.Mac applications on Mac (Via Visual Studio for Mac). The profiler is a separate process from the IDE, and so, in addition to launching from Visual Studio for Mac, it can be used as a standalone application to examine .exe and .mlpd files which have been produced from the mono log profiler.

Currently, the Xamarin Profiler can be used to test Xamarin.Android apps on Windows (via Visual Studio and Visual Studio for Mac). The profiler is a separate process from the IDE, and so, in addition to launching from Visual Studio, it can be used as a standalone application to examine .exe and .mlpd files which have been produced from the mono log profiler.

Profiler Support

Support for the Xamarin Profiler is available on the following platforms:

  • Visual Studio for Mac (macOS, with Enterprise License)

    • Android
      • Device and Emulator
    • iOS
      • Device and Simulator
    • tvOS (Time Instrument is not supported)
      • Device and Simulator
    • Mac
  • Visual Studio (Only Enterprise Version)

    • Android
      • Device and Emulator
    • iOS [Experimental]
      • Device and Simulator
    • tvOS
      • Device and Simulator

Note that you can only profile Debug configurations.

Profiler Basics

This section introduces the parts of the Xamarin Profiler and tours its features.

Allow Profiling in your App

Before you can successfully Profile your app, you will need to allow Profiling in the app's Project Options.

  • iOS:

Build > iOS Debug > Enable Profiling

Properties > iOS Build > Enable Profiling

  • Android:

Build > Android Debug > Enable Developer Instrumentation

Build > Android Debug > Enable Developer Instrumentation

Launching the Profiler

The Xamarin Profiler can be launched from your IDE when you are profiling your iOS or Android application, or as a standalone application.

Launching from Visual Studio for Mac

  1. First, make sure you have your application loaded in Visual Studio for Mac, and select the (default) Debug configuration.
  2. Browse to Run > Start Profilingin Visual Studio for Mac, or Analyze > Xamarin Profiler in Visual Studio, to open the Profiler, as demonstrated in the diagram below:

Launching from Visual Studio

  1. First, make sure you have your application loaded in Visual Studio, and select the (default) Debug configuration, as specified above.
  2. Browse to Analyze > Xamarin Profiler in Visual Studio, to open the Profiler, as demonstrated in the diagram below:

If the menu items do not appear, refer to the troubleshooting guide.

This launches the Profiler and automatically starts profiling the application.

The Profiler can be used to measure memory and performance. It achieves this through the Allocations and Time Profiler instruments, which we will explore in detail in the next section.

Saving and Loading Profiler Sessions

To save a profiling session at any time, choose File > Save As... from the Profiler Menu bar. This saves the file in mlpd format, a special, highly compressed format for profiling data.

After it has been installed the Xamarin Profiler can be found in your Applications folder as illustrated in the screenshot below:

After it has been installed the Xamarin Profiler application can be found in your Application directory:

You can load .mlpd files into the Profiler by opening the standalone application, selecting Choose Target and loading the file.

For more information, see Generating .mlpd Files.

Profiler Features

The Xamarin Profiler is composed of five sections as illustrated below:

  • Toolbar – Located at the top of the profiler, this offers options to start/stop profiling, select a target process, view the running time of the app, and select the split views that compose the profiler application.
  • Instrument List – This lists all instruments loaded for the profiling session.
  • Plot Chart – These charts relate horizontally to the relevant instruments in the instrument list. A slider (shown beneath Time Profiler) can be used to change the scale.
  • Instrument Detail area - Contains data being displayed by the selected view of the current Instrument. We will look at these views in more detail in the section below.
  • Inspector View – This contains sections that can be selected by the segmented control. The sections are dependent on the instrument selected, and includes: Configuration Settings, Statistics, Stack Trace information, and Path to roots.

Allocations

The allocations instrument provides detailed information about objects in the application as they are being created and garbage collected.

At the top of the profiler is the allocations chart, which displays the amount of memory allocated at regular intervals during the profiling. Currently the allocations graph is the total number of allocations and NOT the size of the heap at that point in time. In a sense, it will never go down, it will only ever increase. This includes objects allocated on the stack. Depending on the runtime version used, the chart can look different – even for the same app.

There are different data views in the Allocations instrument, which allow developers to analyze how their application is using and freeing memory. These views are described below:

  • Allocations – This displays a list of all allocations and groups them by class name. This provides a great overview of classes and methods being used, how often they are used, and the collective size of the classes used. Double clicking on a class will show the memory allocated :

The Inspector view for Allocations provides options for filtering and grouping objects, providing statistics on memory allocated, and the top allocations, as well as views for Stack Trace and Path to Root.

  • Call Tree – This displays the entire call tree of all threads in the application and includes information about the memory allocated on each node. When an element is selected in the list, all sibling nodes will appear grey. You can expand the tree or double-click the element to drill down into it.When displaying this data view, the display settings inspector view can be used to change the way it is presented. There are currently two options:
    1. Inverted Call Tree – This considers the stack trace from top to bottom. This is a convenient view option as it indicates the deepest methods where the CPU has been spending its time.
    2. Separate by thread – This option organizes the call tree by thread.
  • Snapshots – This pane displays information about memory snapshots. To generate these while profiling a live application, click the Camera button in the toolbar at each point that you'd like to see what memory is retained and released. You can then click each snapshot to explore what is happening under the hood. Note that snapshots can only be taken when live profiling an app.

Time Profiler

The Time Profiler instrument measures exactly how much time is spent in each method of an application. The application is paused at regular intervals and a stack trace is run on each active thread. Each row in the Instrument Detail area shows the execution path that has been followed.

The plot chart, as shown in the screenshot below, displays the number of samples received by the app as it runs:

  • Call Tree – Shows amount of time spent in each method:

Cycles

Perf Tool For Mac

Through the use of C# and F# managed code, it can be quite common, and unfortunately quite easy to create references to objects which will never be disposed. This instrument allows you to pinpoint those objects, and display the cycles referenced in your application.

Profiling Applications

Mac

Currently, only the default Debug configurations can be profiled.

If you profile an app with any other configuration, you will be presented with the following message dialog:

Select Update to continue.

SGen Garbage Collector and Profiling

The SGen garbage collector is used for all Xamarin platforms.

SGen is a generational GC, which allocates objects of an application into three heaps — Nursery, Major Heap and the Large Object Space. This allows for speedier execution of garbage collection. SGen is currently the default GC for Xamarin.Android, and Xamarin.iOS Unified applications.

Perf Tool For Mac Torrent

Xamarin.iOS application using the Classic API used the Boehm GC – a conservative, non-generational garbage collector. As it is conservative, it is less likely to free up available memory, which can lead to inaccurate results when using the profiler. For this reason, the Allocations instrument cannot be used with the Boehm garbage collector.

Perf Tool For Mac Windows 7

While you will be prompted with a message dialog if your app uses the Boehm GC, Xamarin does not recommend switching existing iOS application that use Boehm to SGen without careful research and thorough testing. Xamarin also does not recommend switching to SGen for profiling and then switching back, as these results will not provide accurate benchmarks of memory usage.

For more information on memory management, refer to the Memory and Performance Best Practices guide.

Summary

In this guide we looked at what profiling is and how it is advantageous to the developer. We then introduced the Xamarin Profiler, providing some history and information into how it works. Finally we toured the features of the Xamarin Profiler, and explored the Allocations and Time Profiler Instruments.

Related Links