Join Simon Allardice for an in-depth discussion in this video Code analysis tools, part of Foundations of Programming: Code Efficiency.
So I said, we don't know what the problem is until we measure it. Time to start measuring. There are several different terms used for this idea of measuring a computer program and how well it's performing. We could say we are monitoring profiling, tracing, benchmarking or just performance analysis. These are all common terms you'll hear. And they aren't often used interchangeably. But they don't mean exactly the same thing. Benchmarking, for example, is often, but not always, used for the idea of a set of standardized tests.
For, say, comparing several graphics cards, or several comparable databases with each other. And profiling. Which is the term probably most useful for us, as developers. Is usually referring to the idea that we're not just measuring a snapshot of our application, its memory, its cpu, and so on, at that one instant in time. But rather, how it changes over a period of time. Whether that's, five seconds, five minutes, five hours, five days. In this section of the course, we're going to explore quite a variety of software utilities for analyzing and measuring the behavior of different areas of an application.
CPU, memory, disk I/O, network traffic. Now some of these tools might be useful to just to let us know roughly where our problem is, and others for drilling down not just deeply, but very deeply into it. Now my aim in this section is not to make you an expert on any of them, some of these tools we can have an entire course on by themselves, but rather to introduce you to the different options, so you know what's available to you, and if you see an utility you think is going to be useful, you know where to go. Now I am going to cover examples about pc and Mac operating systems, I want to specifically do a section on Linux, but as the Mac is Unix based, many of the same options are available on Linux.
But a word of warning. When we're going through these tools for the first time, we should take care to stay focused. Know that many of these utilities that I'm about to demonstrate are not just intended for us here in this situation, meaning they're not just used for efficiency problems, they're also used to find bugs even very complex and serious bugs. And not just in regular apps, but in system level application. They're used to monitor the health of an overall operating system. And because of that, quite a few are aimed more at system administrators than developers.
So expect to see that some of these will present us with a massive amount of data, not just about our application but often about all the other applications running on the machine, everything else that’s going on in the background, and we will need to filter down and ignore most of it so we can focus on something that’s actually useful for us. I'll go through them in four sections, beginning with the most general tools, the ones already built into the operating system right out of the box, the ones most power users already know.
Activity monitor and task manager. Then I'll explore some specialized utilities, even some very specialized ones not necessarily focused just for us as developers. These include command line tools that that will let us drill into one specific area like, just memory, or just the amount of disc reads and writes being performed by an application. After that, I'll go through a few developer-focused options that your chosen development environment, like Eclipse, or Visual Studio, or X Code.
They'll often have their own way to examine some of this information. And finally, I'll cover a couple of web-focused tools, built into modern web browsers. These are often a very convenient way to monitor and examine several areas of a browser web application. But they only work for that kind of application, so they're not as general as the other tools we're going to see.
Learn to choose the right data types, understand the pitfalls of using high-level languages, and decide where to spend your time. Plus, see how the underlying memory management model may have more of an impact than you realize, and what performance issues you can expect working with databases and web services.
- Identifying problems in the code
- Embracing constraints
- Using code analysis tools to measure performance
- Managing memory
- Managing disk-based and network resources