Reading:
Software Optimisation and Performance Profiling

Image

Software Optimisation and Performance Profiling

How to Deal with Performance Problems in Software Development

As most readers are probably aware, software optimisation is essential to maintaining well-functioning software products, but this can also vary considerably depending on your product’s individual requirements. After all, while for some applications, it is acceptable to wait a second or two for requests to process, other solutions are required to handle literally billions of requests per second. Concurrently, when working with legacy systems, performance can also deteriorate over time, leading to a slew of other challenges which are in fact in a category of their own. In any case, however, if performance is not in alignment with your developers’ expectations, then it is probably time to resort to optimisation – whether employing performance profiling tools or any other optimisation approach.

Types of Software Performance Optimisation

There are several possible measures to optimise performance. Some of the most common approaches include:

Measure

Description

✅

Profiling

Measuring and analysing the performance of the application with the goal of identifying bottlenecks and any opportunities for improvement.

✅

Caching

Storing frequently accessed data in a cache to quickly retrieve it. Caching can be easily implemented at the database or content level.

✅

Optimising data structures and algorithms

Selecting and implementing the best data structures and algorithms for the specific problem at hand (e.g. those resulting from an increased user base).

✅

Concurrent and parallel processing

Using multiple cores or processors to perform several computations at once. This can greatly speed up execution.


✅

Reducing network calls

Bringing down network latency by minimising the amount of network calls made by the application. This is usually accomplished by shifting processing to the backend or frontend.


✅

Minimising I/O operations

Decreasing the number of input/output operations in the database or filesystem to speed up the application.


✅

Reducing memory usage

Lowering the amount of memory used to avoid overloading the system.


✅

Optimising database queries

Optimising the queries themselves to improve the way data is requested.


✅

Reducing server load

Decreasing the load on the server if the same can be done on the client side without any problems.


✅

Code refactoring

Restructuring the code as needed to reduce complexity and improve readability.


It is worth pointing out that these approaches are not mutually exclusive, and often several of them have to be applied together to achieve a noticeable performance improvement. Nevertheless, profiling is more often than not a logical starting point, as it essentially helps to reveal the most problematic areas of the system. Thankfully, there are plenty of tools which can also make this process less painful through automation.

How to Deal with Performance Problems in Software Development Img
Software Optimisation and Performance Profiling

Code Quality vs Performance

On that note, it is equally important to mention that when optimising software products, code quality can be a detriment to performance. In other words, while the structure of one’s code and architecture may be practically perfect in theory, it might be doing more harm than good in practice.
In such cases, the clarity of the source code may suffer. Yes, from time to time, performance optimisation requires destroying beautiful code constructions for the sake of high-speed operations.

Locating Bottlenecks

Especially when dealing with legacy systems, the right approach to optimising performance may not always be immediately obvious. You may not know if you should update your data structure, implement caching, or even set up a CDN, for instance. Consequently, it is important to ensure that you thoroughly understand your existing bottlenecks. This will enable you to prioritise optimisation based primarily on the obstacles you are facing. After all, different system components will naturally each have different values for the user – and potentially even different costs. When looking for bottlenecks, profiling should be your first course of action.

What Are Profiling Tools?

In a nutshell, performance profiling tools are software tools that enable developers to not only assess the performance of an app, but also optimise underperforming code. They provide key metrics regarding the space (memory) or time complexity of a program, the usage of particular instructions or the frequency and duration of function calls.

Profilers can aid software optimisation because they are used to check programs whenever they are run, and provide developers with invaluable feedback. Moreover, outputs may range from anything like simple summaries to a recorded stream of events and developers can use code profiling in a variety of different languages and frameworks.

In other words, instead of relying on questionable guesswork, you can optimise based on actual data.

Two Sides of the Same Coin: Client & Server Profiling

Software performance profiling is a term that covers the vast majority of optimisation activities. It can be employed in a variety of different types of software systems. Depending on your company’s solution, it can also be used on the client side, server side or both.

Client-side profiling

The objective of client-side profiling is to analyse and measure any point of interaction with the user. A few common examples of client-side profiling tools include:

  • Browser-based developer tools (e.g. performance profilers in Chrome DevTools and Firefox’s Developer Tools).
  • JavaScript libraries (e.g. the User Timing and Performance Timeline APIs, which enable developers to measure and track the performance of specific parts of code).
  • Third-party performance monitoring and profiling tools (e.g. WebPageTest and Lighthouse, which provide in-depth performance metrics and analysis of websites and apps).
  • Framework-specific performance profiling (e.g. Angular’s Augury, Vue’s Vue-devtools and React’s own performance profiler).
  • Code-level profiling (e.g. Safari Web Inspector, Firebug and Internet Explorer F12 Developer Tools, which help developers analyse the performance of client-side JavaScript code in the web browser).

Server-side profiling

On the other hand, server-side profiling tools are employed to measure and analyse the performance of server-side code in addition to the underlying infrastructure. Examples of server-side profiling tools include:

  • Xdebug: an extension with code debugging and profiling capabilities for PHP.
  • Blackfire: a PHP performance optimisation tool that can be used to profile web applications and identify any bottlenecks in performance.
  • New Relic: an extremely popular profiler for monitoring web applications and infrastructure.
  • AppDynamics: a performance monitoring tool for profiling web applications.
  • Apache JMeter & Gatling: widely used load testing tools that are able to measure the performance of web applications under heavy load.
  • Others: tools like sysdig, perf and dtrace that can profile the performance of the underlying system.

These are just a few examples of the many server-side profiling tools available for web application development. Remember that finding the right tool to use will not only depend on the specific needs of your project, but also on your current tech stack.

Other Types of Profilers

More specific types of software, such as mobile or desktop applications, call for a slightly different approach. Because these apps will often make use of the native features of the hardware they are running on — gyroscope, camera, nfc readers, etc. — developers naturally had to devise a whole array of profiling instruments.

Profiling tools for mobile development:

  1. Code-level profilers: provide code-level information regarding the CPU, memory usage, network requests and other performance metrics of iOS and Android apps (e.g. Flipper for React Native).
  2. Memory profilers: help identify and track memory leaks, which can often result in stability issues and poor performance (e.g. Memory Analyzer Tool for Android).
  3. Battery profilers: enable you to discover which parts of an application are consuming the most battery power, so developers are free to optimise them (e.g. PowerTutor and Battery Historian).
  4. Network profilers: allow developers to analyse and track network activity, such as how much data is being sent and received, as well as the performance of network requests. This can help prevent runaway roaming costs (e.g. Fiddler, Charles Proxy and Wireshark).
  5. Third-party performance monitoring and profiling tools: popular tools like Bugsnag, Instabug and AppDynamics can provide a full range of features including crash reporting and real-time insights.

Note that some of these tools are platform specific and will only work on iOS or Android.

Platform-specific profilers

Many mobile platforms, including iOS and Android, have built-in profilers that consider the particulars of every device and can be used to measure performance metrics such as memory use and network activity.

Profiling tools for iOS:

There are several platform-specific profilers used exclusively for iOS:

  1. Instruments: a suite of performance analysis and testing tools built directly into Xcode, the development environment for iOS applications. Beyond tracking leaks and measuring energy usage, Instruments enables developers to profile CPU and memory use, network activity and more.
  2. Core Animation: a tool built into iOS itself that allows developers to visualise the frame rate, layers and timing of each animation as well as other performance metrics of the application. This information can then be utilised to improve the visual effects and animations.
  3. Time Profiler: an instrument within the Instruments suite providing detailed information about the app’s CPU usage, and helping identify any parts in the code that are taking up the most system resources.
  4. Allocation Profiler: another instrument within the Instruments suite that provides a detailed view of memory allocation and deallocation in iOS applications. It allows developers to find out exactly what objects are being created and when, as well as how much memory every object is using.
  5. Memory Graph Debugger: a tool enabling developers to debug memory usage in their applications. It does so by creating a visual representation of the objects in the memory heap — in addition to the relationships between them — to help visualise and analyse memory usage in real-time.
  6. Energy Log: another tool enabling developers to monitor and analyse the energy usage of applications, with the goal of improving their performance and battery life. It provides detailed information on the power consumption of different parts of the app, including CPU and network.
  7. Third-party performance monitoring and profiling tools: Shark, Reveal and SimPholders are all worth looking into.
Profiling tools for Android:

There are also several types of profilers that can be used for Android application development, including:

  1. Android Profiler: a built-in tool in Android Studio, the development environment for Android applications. Android Profiler enables developers to profile CPU and memory usage, network activity and more, and it can also be used to measure energy utilisation, track leaks and identify bottlenecks.
  2. Traceview: a legacy profiling tool that is often employed by developers to profile the performance of Android apps. It displays key performance data in the form of method call graphs, which help make sense of the flow of execution in the code. Traceview can also display call stacks and thread information, to help developers locate the source of performance problems.
  3. Systrace: a command-line tool for Android devices that provides a graphical representation of the operating system and application activity. It can be used to analyse CPU usage, I/O activity and other system-level events.
  4. Memory Monitor: a built-in tool in Android Studio allowing developers to track memory usage over time and identify potential leaks. Memory Monitor includes information about the heap size, memory allocations and garbage collection events.
  5. GPU Profiler (gprof): yet another command-line tool in Android Studio that enables developers to monitor the GPU usage of their applications. It offers information about the execution time of functions, including how much time was spent in each function and how many times it was called. This can help identify performance issues related to GPU use.
  6. Other performance monitoring and profiling tools: Leak Canary, Stetho and MAT (Memory Analyzer Tool) can also be used to profile and analyse the performance of android apps.

Profiling tools for desktop development:

There are several types of profilers that are commonly used for desktop application development, including:

  1. Platform-specific profilers: many desktop platforms, like Windows and MacOS, have built-in profilers that can be used to measure performance metrics such as CPU and memory usage and network activity. Examples for Windows include the Task Manager and Windows Performance Analyzer (WPA), while MacOS comes with the Activity Monitor and Terminal.
  2. Code-level profilers: these tools enable developers to measure the performance of specific sections of code or functions within a program.
  3. Memory profilers: help identify and track memory leaks, which can often lead to stability issues and poor performance.
  4. Third-party performance monitoring and profiling tools: XHProf, YourKit, Intel VTune Profiler and others include detailed performance metrics and analysis of desktop applications.

These tools can also be integrated with integrated development environments (IDEs) — e.g. Visual Studio, Eclipse and Xcode — which enable profiling code directly from the development environment.

Performance Profiling or Performance Testing?

While undoubtedly related concepts, performance testing and profiling are surprisingly distinct from one another.

Performance profiling

Performance profiling not only focuses on how an application uses resources throughout its execution, but how it consequently performs its key functions. Its goal is to identify any bottlenecks in performance, in addition to inefficiencies and other areas for potential optimisation. This is typically done during development and testing, with the help of specialised techniques and tools that can capture detailed application performance data — though it can also sometimes be performed on a fully functioning system.

Performance testing

Unlike profiling, performance testing takes place at the system level and ensures that your system meets its service level agreements (SLAs). It is focused on evaluating the performance characteristics of a software application under realistic or expected load conditions. The goal of performance testing is to identify performance limitations, capacity constraints and any potential issues with scalability or reliability. Performance testing is usually done much later in the development cycle and will involve simulating real-world usage scenarios.

Profiling vs Debugging

Both profiling and debugging are important aspects of the software development process, and they are often used in tandem to identify and resolve stability issues. Unlike profiling, however, debugging refers to the process of identifying and fixing errors (or “bugs”). It involves debugging tools, like debuggers and trace logs, that are used to analyse the code, examine variable values and identify the root cause of the problem. In general, while profiling can help highlight code areas that might be causing performance problems, debugging is used to identify and fix specific errors in the code.

The Ideal Profiler: What Are the Features?

Ease of use

Ideally, developers should use a profiler that can easily detect performance problems in their code. If in order to complete a basic task, you first have to jump through a series of hoops, then you should likely look for a simpler alternative. Concurrently, due to the growing need to produce high-quality apps as quickly as possible, developers don’t have the time to deal with unnecessarily complicated tools. Profilers are designed to help accelerate the development process. These tools should have a simple learning curve and be immediately usable by developers.

Multiple measurements

Profilers should also be versatile, enabling developers to analyse performance in a variety of different ways. This ensures that their systems are performant in all the required areas, including memory allocation and operating system resource use. Furthermore, to give software engineers adequate time to complete these operations, switching between them should also be rapid, intuitive and straightforward.

Detailed reporting

A profiler’s information is useless unless we can describe it both clearly and thoroughly. The profiler’s output, whether HTML pages or Microsoft Word documents, has to not only be well presented but also easy to interpret. The reporting system should similarly be robust, providing the details developers require whilst staying flexible enough to enable data filtering and presenting only the relevant information.

TOP 10 Performance Profiling tools

With that in mind, listed below are the top performance profiling tools today. In any case, however, remember that the popularity of profiling tools might potentially be less important depending on the platform and programming language being employed, as well as the specific requirements of your project:

  1. Xcode Instruments
    A suite of performance analysis tools for iOS, macOS and iPadOS development. It is built directly into Xcode, Apple’s integrated development environment (IDE), and offers a range of performance analysis and profiling features.

  2. Android Profiler
    A set of performance analysis tools for Android development that is integrated into Android Studio. It provides real-time data for CPU, memory, network and GPU usage, as well as detailed recordings of system traces to help diagnose performance issues.
  3. Visual Studio Profiler
    A performance analysis tool for .NET development that is integrated into Visual Studio. The profiler works by collecting performance data while the application is running, and presenting the information in a straightforward manner.
  4. Perf
    Typically used on the command line, `perf` is a popular performance analysis tool for Linux systems. It can be used to collect, visualise and analyse performance data. Perf offers a range of functionality, including measuring hardware performance events, tracing function calls and profiling CPU usage.
  5. JProfiler
    A performance analysis tool for Java development, available both as a standalone app or as a plugin for Java IDEs. It provides detailed information about the Java runtime environment, including class loading, garbage collection and JVM internals, which allows developers to gain deeper insight into their applications.
  6. Chrome DevTools
    A set of performance analysis tools for web development that is fully integrated into the Google Chrome web browser. It includes features such as a JavaScript console for entering and executing code in real-time, a DOM inspector for examining the structure of a web page, a network panel for analysing resource loading and network performance, and a JavaScript profiler and memory panel.
  7. OProfile
    Typically used on the command line, OProfile is a system-wide performance analysis tool for Linux. It is capable of profiling all running processes and the Linux kernel and offers detailed performance information, including data about the frequency and duration of function calls.
  8. New Relic
    A performance management platform for modern software applications. It provides a comprehensive set of performance analysis and monitoring tools for various types of applications and technologies, including web applications, mobile applications and cloud services.
  9. Apache JMeter
    A popular open-source performance testing tool used by software developers, quality assurance engineers and DevOps teams. It comes with a range of advanced features, such as the ability to create complex test plans, customise test scenarios and analyse results through detailed charts.
  10. Gatling
    Our final pick for the top 10 is Gatling, another popular open-source tool that is designed for high performance testing. It provides a high-level API for creating performance tests, as well as a user-friendly web interface for analysing test results. Gatling also supports a number of protocols, including HTTP, HTTPS and WebSockets, and enables users to create complex test scenarios, simulate real-world user behaviour and measure response times, throughput and error rates.

Why CEOs and CTOs Should Care About Software

Optimisation

CEOs and CTOs should care about profiling tools in software development because they play a critical role in optimising the performance of software applications. By understanding the main principles of optimisation and knowing which tools can be used and where, executives gain valuable insight into performance bottlenecks and any areas for improvement in their software. This information can then be repurposed to make informed decisions on allocating resources, prioritising development tasks, and improving the efficiency and user experience of their software. As a result, equipped with the knowledge of the available range of profiling tools, both CEOs and CTOs can ensure their software development team is utilising their time and resources effectively, using the right tools for the technology and type of product they have. This leads to better overall outcomes and a more successful business.

Are you looking to improve your software’s performance?

Book a free consultation with one of our specialists to assess your infrastructure and put together an optimisation plan

Get a Quote

Related Stories

What is Reinforcement Learning
March 7, 2023

Why Reinforcement Learning Matters and How It Can Help Your Business

Reinforcement learning is a powerful type of machine learning algorithm that is rapidly gaining traction in the business world.

What is Gitflow
November 12, 2020

What Is Gitflow and Why Should You Use It?

Git and often Gitflow have become a de facto standard. Read more about how they enable working collectively with the source code and other artefacts.

Fun With NLP