A Student's Guide to Software Engineering Tools & Techniques »

Performance Profiling

Author: Ong Heng Le


A performance profiler is a tool which collects data (such as function timings) about your program to identify the areas with performance issues, commonly used in code optimization. There are two common types of performance profiling methods.

  • CPU sampling: Collects samples at fixed intervals, which provides an overview of your program's performance
  • Instrumentation: Collects detailed elapsed times for your program's function calls

Learn which profiling method to use for your program when choosing between CPU sampling and instrumentation.

Performance Profiling for the First Time

This article provides resources to help you identify the performance issues as you perform profiling on your program for the first time. The general steps in profiling a program for the first time are:

  1. Run a performance profiling session
  2. View the performance report
  3. Trace down to the problem
  4. Identify areas for improvements upwards

Most profilers are similar in their functionalities, user interface, and use of technical terms. You may adapt the tutorials in this article to your preferred profiling tools on your own project.

Advanced Topics

Sampling Interval

CPU sampling captures data at fixed intervals, usually based on CPU cycles or time. Many profilers offer the option to set a custom interval or perform sampling based on events, such as page faults or system calls, in the sampling settings.

Instrumentation Overhead

Instrumentation profiling incurs a substantial overhead, which is an increase in file size and execution time of the program. This makes it unsuitable for large projects. In such cases, it is recommended to limit instrumentation to a specific portion of your project.

To reduce instrumentation overhead, some profilers may exclude small functions, which are short functions that do not make any function calls, and treat the time as being spent in their calling functions. This behavior is usually enabled by default, which may be undesirable when you want to examine small functions carefully. Most profilers offer the option to change this behavior.

Profiling Other Types of Data

Other than collecting performance statistics and timing data, profilers are also able to collect other information such as memory allocation and GPU usage.

For Visual Studio 2015:

  1. List of Profiling Tools (A table which shows the most suitable tool for each project)
  2. How to: Collect Performance Data for a Web Site (ASP.NET and JavaScript)
  3. Collecting .NET Memory Allocation and Lifetime Data
  4. Collecting Thread and Process Concurrency Data
  5. Collecting tier interaction data


  1. What is a software profiler?: Profiling Overview
  2. Common performance profiling methods: Understanding Performance Collection Methods
  3. Learn the best practices in profiling: Advanced Profiling: Theory in Practice with NetBeans IDE
  4. Why do profilers exclude small functions from instrumentation by default?: Excluding Small Functions From Instrumentation