Performance Test - Function Performance Analysis
-Quantify
After using the ACT (Application Center Test), how to locate the module of the discovery performance problem, discover the performance bottleneck, which requires you to know a performance analysis tool, Rational Test Suite's Quantify. Quantify is a functional analysis tool for VB, VC, Java, which automatically detects performance bottlenecks that affect program running, and provides graphical analysis forms to help programmers analyze and optimize.
In the process of performance optimization, some programmers often analyze their own code with experience, find performance bottlenecks, which will face two issues:
1. The performance bottleneck of the programmer is likely to be an algorithm that it thinks is unreasonable, but in the process of optimization, everyone knows that performance optimization is often unreasonable, but the main optimization takes longer. function;
2, in a large project, how to find a performance bottleneck in thousands of code is a biggest headache, if you don't know the project, you can't get started;
So how to efficiently increase the problem, not the problem of checking the code, and Quantify is a kind of artistic weapon.
Quantify has the following features:
1. The current development has little particularly small, but also integrates in some universal development tools, greatly enhances the easy degree of use, such as Visual Studio;
2
3. No source code can be analyzed for most systems;
4, the information of the function of the display is very detailed, including the number of times, time, etc., and related call relationships;
5. While testing, the performance is analyzed, and additional auxiliary code is not required;
The following is a detailed introduction to how to perform performance analysis and discover problems with Quantify. Here I use cppunit to write a test case to test the code with problems with a performance (the code is not sent, huh, huh), Mainly through it, you know that QUAntify is a very simple tool:
l The performance test only needs to run compilation programs, as shown:
Figure 1
l The result of the generated is shown in Figure 2, especially simple:
Figure 2
However, it is necessary to have the following points, including the following points, give you a few knowledge, just understand, if you need detailed understanding, these are not enough:
1. Function Time: The time executed by the function itself, it does not contain the time of the sub-function;
2. F D Time (Function Descendants): The function of the function itself is executed with the subunies called by the function;
3. Calls: The number of times the function is called during the execution;
4. f Time (%): It is a percentage of the function itself (not included) occupies the entire system runtime;
5. F D Time (%): Yes, the function itself consumes time plus sub-function time accounts for the percentage of the entire call time;
6. AVG F (TIME): The main means average operational time;
7. Min F (Time): The smallest runtime during the function call;
8. MAX F (Time): The maximum running time during the function call;
9. Module: It is the DLL call; in the performance analysis process, there is a principle that optimizes the longest function of the occupancy or the longest function, so I will first pay attention to Function Time and F Time (%) This is sorted, thus discovering problems in performance, of course, modules are related to their own systems, as shown in the figure:
Figure 3
Here you can see that the system's output function is the system's output function. Its Calls is very high, and it is very much very much in occupancy time and percentage. Oh, you can know that this is the system-related performance bottleneck I do this in my code, huh, huh.
/ / Demo Performance Test
Void cmabstring :: demoperty ()
{
COUT << "Begin Performance / N";
Int results = 0;
For (int J = 0; j <1000; j )
{
COUT << "this ispeformance test / n";
}
COUT << "End Performance / N";
}
Of course, you can also find that your function consists of those subunies through graphics, as shown in the figure:
Figure 4
From here you can see CMAbstring :: demoper The subunies of the following calls are OSTEAM, the number of calls is 1002, accounting for 99.80% of performance; also can see the previous function, that is, call cMabstring :: demoper function Mathtest :: TestDemper, you can see the call relationship between the functions through graphics, while you can track its call relationships and performance, but it is important to note that there is a possibility of possible subunies calls The performance of the occupied performance can even exceed the previous grade function, why, mainly here show the number of calls to the process, that is, this function may be called in other places, so this is a normal phenomenon. However, if the system is accidental or the tool is not familiar with the tool, I have been dizzy, I have been dizzy, how many times, haha. The above example is very simple, that is, the cycle occupies time.
The above analysis is only positioned to the function, but can it be positioned to the source level? The answer is yes. As long as there is a source code, you can analyze from the source level. You can clearly see the execution time of each code, execute the function, through this method, you can position the problem faster, as shown below:
Figure 5
Here, Linetime is the execution time of this line itself. Line D is the time execution time of the line execution time and the subtree, and through the source level analysis, you can see the performance bottleneck of this code in the For loop, of course, not necessarily optimized, but If it is optimized, it will increase the most obvious.
But performance issues are not just code [written, and some are issues of database issues or network transmission, etc. If you find that if you call the database method, you can transfer Network library or analysis of databases.
Quantify has other convenient places. For example, the preservation of the analysis is very convenient, supporting multiple languages, of course, tools are not universal, the most important is human factors, hoping to improve your performance analysis capabilities through tools.