Performance test method and device, electronic equipment and storage medium
By generating a test script containing step size rules, gradually increasing the number of threads to determine the optimal number of threads, the existing performance test problems are solved, and a more comprehensive and accurate performance evaluation is achieved.
Patent Information
- Application Number
- CN202411353115.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-09-26
- Publication Date
- 2024-12-13
AI Technical Summary
The existing performance testing methods are inefficient and labor-intensive, and the results are not accurate and comprehensive enough, especially the performance performance at different load levels is not fully evaluated.
By determining performance indicators and test scenarios based on business needs and system characteristics, a test script containing the first step length rule and the second step length rule is generated, the number of threads is gradually increased and performance tests are performed, and the number of critical threads and candidate threads are determined based on the test data is determined. , finalize the optimal number of threads to improve the accuracy and comprehensiveness of the test results.
Improve the accuracy and comprehensiveness of performance testing, reduce labor consumption through automated testing processes, and enable more accurate evaluation of the system's performance at different load levels.
Smart Images

Figure CN119127716A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of computer technology, and in particular to a performance testing method, device, electronic device and storage medium. Background Art
[0002] Performance testing is to test the performance indicators of the system by simulating various normal, peak and abnormal load conditions through automated testing tools. Both load testing and stress testing belong to performance testing, and the two can be combined. Through load testing, the performance of the system under various workloads is determined. The goal is to test the changes in various performance indicators of the system when the load gradually increases. Stress testing is to obtain the maximum service level that the system can provide by determining the bottleneck or unacceptable performance point of a system.
[0003] The current performance testing solutions are generally manual testing, which consumes a lot of manpower and requires real-time data analysis. In addition, the performance estimates are relatively broad, and the performance test results may not reach the limit. During the performance test, the test parameters and the number of threads need to be adjusted manually repeatedly, which is inefficient. In addition, the current performance test only focuses on the maximum load that the system can withstand, while ignoring the performance of the system at different load levels. This may lead to an incomplete response to the system's performance under low load, high peak load, etc.
[0004] Therefore, there is an urgent need to propose a performance testing method, device, electronic device and storage medium that can improve the accuracy and comprehensiveness of performance testing results. Summary of the invention
[0005] Based on this, it is necessary to provide a performance testing method, device, electronic device and storage medium that can improve the accuracy and comprehensiveness of performance testing results in response to the above technical problems.
[0006] In a first aspect, a performance testing method is provided, the method comprising:
[0007] Determine performance indicators and build test scenarios based on business requirements, user scenarios, and system characteristics;
[0008] Generate a test script based on the performance indicator and the test scenario, wherein the test script includes at least a first step length rule, a second step length rule, and a termination condition, and the thread growth rate in the first step length rule is greater than the thread growth rate in the second step length rule;
[0009] According to the first step length rule, gradually increase the number of threads of the system from 1, and perform performance tests on the system in sequence to obtain first performance test data;
[0010] Determine the number of critical threads and the number of first candidate threads according to the first performance test data and the termination condition;
[0011] According to the second step length rule, gradually increase the number of threads of the system from the critical number of threads, and simultaneously perform performance tests on the system in sequence to obtain second performance test data;
[0012] Determine the second number of candidate threads according to the second performance test data and the termination condition, and determine the optimal number of threads according to the first number of candidate threads and the second number of candidate threads;
[0013] A performance test is performed on the system according to the optimal number of threads to obtain third performance test data.
[0014] In one embodiment, determining the number of critical threads and the number of first candidate threads according to the first performance test data and the termination condition includes:
[0015] Sorting the first performance test data in order of the number of threads from small to large, and comparing each first performance test data with the termination condition in turn;
[0016] The number of threads corresponding to the first performance test data that first meets the termination condition is used as the first candidate thread number;
[0017] According to the first number of candidate threads and the first step length rule, the number of threads previous to the first number of candidate threads is obtained, and the number of threads previous to the first number of candidate threads is used as the critical number of threads.
[0018] In one embodiment, determining the second number of candidate threads according to the second performance test data and the termination condition, and determining the optimal number of threads according to the first number of candidate threads and the second number of candidate threads, comprises:
[0019] Sorting the second performance test data in order of the number of threads from small to large, and comparing each second performance test data with the termination condition in turn;
[0020] The number of threads corresponding to the first second performance test data satisfying the termination condition is used as the number of second candidate threads;
[0021] Comparing the number of the first candidate threads with the number of the second candidate threads;
[0022] In response to the first candidate thread number being greater than the second candidate thread number, the first candidate thread number is determined to be an optimal thread number.
[0023] In one embodiment, performing a performance test on the system according to the optimal number of threads to obtain third performance test data includes:
[0024] Repeating the performance test on the system with the optimal number of threads according to the test times in the test script to obtain fourth performance test data;
[0025] Sorting the fourth performance test data in order from large to small or from small to large;
[0026] According to the sorting result, remove the first fourth performance test data and the last fourth performance test data, and calculate the first average value of the remaining fourth performance test data;
[0027] The first average value is used as the third performance test data.
[0028] In one embodiment, before sorting the fourth performance test data in order from large to small or from small to large, the method further includes:
[0029] Calculating a second average value of the fourth performance test data, and calculating a difference between each fourth performance test data and the second average value;
[0030] Setting an error threshold, and comparing the difference value corresponding to each fourth performance test data with the error threshold;
[0031] In response to the difference corresponding to the fourth performance test data being greater than the error threshold, the fourth performance test data is determined to be abnormal data, and the abnormal data is deleted.
[0032] In one embodiment, the first performance test data satisfying the termination condition is obtained by:
[0033] Compare various types of data in each first performance test data with thresholds of corresponding types in the termination condition, wherein the various types of data include memory occupancy, disk load percentage, and bandwidth usage, and the corresponding types of thresholds include memory occupancy percentage threshold, disk load percentage threshold, and bandwidth usage percentage threshold;
[0034] In response to any type of data in the first performance test data exceeding a threshold of a corresponding type in the termination condition, it is determined that the first performance test data satisfies the termination condition.
[0035] In one embodiment, generating a test script based on the performance indicator and the test scenario includes:
[0036] Generate a test plan based on the performance indicators and test scenarios, and generate the test script based on the test plan, wherein the test plan includes a performance testing tool;
[0037] The performance testing tool is obtained in the following way:
[0038] Acquire a performance testing tool framework written in a target programming language, wherein the performance testing tool framework includes a first test class that supports the performance test;
[0039] Using a first conversion method, converting the programming language of the first base class in the first test class into another programming language to obtain a second base class, wherein the first conversion method is a conversion method with a feature of supporting cross-language polymorphism, and the first base class refers to a core class for performance testing in the first test class;
[0040] Using a second conversion method, converting the programming language of the first control class in the first test class into the other programming language to obtain a second control class, wherein the second conversion method is different from the first conversion method, and the first control class refers to a class in the first test class that controls performance test parameters;
[0041] Based on the second base class, obtaining a derived class written in the other programming language;
[0042] A performance testing tool is generated according to the derived class and the second test class, wherein the second test class includes the second base class and the second control class.
[0043] In a second aspect, a performance testing device is provided, the device comprising:
[0044] A first determination module, the first determination module is used to determine performance indicators and build test scenarios according to business requirements, user scenarios and system characteristics;
[0045] A generation module, the generation module is used to generate a test script based on the performance indicator and the test scenario, wherein the test script includes at least a first step length rule, a second step length rule and a termination condition, and the thread growth rate in the first step length rule is greater than the thread growth rate in the second step length rule;
[0046] A first increasing module, the first increasing module is used to gradually increase the number of threads of the system starting from 1 according to the first step length rule;
[0047] A first test module, the first test module is used to perform performance tests on the system in sequence to obtain first performance test data;
[0048] a second determination module, the second determination module being used to determine the number of critical threads and the number of first candidate threads according to the first performance test data and a termination condition;
[0049] A second increasing module, the second increasing module is used to gradually increase the number of threads of the system starting from the critical number of threads according to the second step rule;
[0050] A second test module, the second test module is used to perform performance tests on the system in sequence to obtain second performance test data;
[0051] a third determination module, the third determination module being used to determine the second number of candidate threads according to the second performance test data and the termination condition, and to determine the optimal number of threads according to the first number of candidate threads and the second number of candidate threads;
[0052] The third testing module is used to perform a performance test on the system according to the optimal number of threads to obtain third performance testing data.
[0053] In a third aspect, an electronic device is provided, comprising one or more processors; and a memory associated with the one or more processors, the memory being used to store program instructions, which, when read and executed by the one or more processors, execute the steps of the method described in any one of the first aspects above.
[0054] In a fourth aspect, a computer-readable storage medium is provided, on which a computer program is stored. When the computer program is executed by a processor, the steps of the method described in any one of the first aspects are performed.
[0055] In a fifth aspect, a computer program product is provided, comprising a computer program, wherein when the computer program is executed by a processor, the steps of the method described in any one of the above-mentioned first aspects are implemented.
[0056] The above-mentioned performance test method, device, electronic device and storage medium increase the number of threads from 1 according to the first step length rule, and determine the critical number of threads and the first candidate number of threads according to the termination condition; increase the number of threads from the critical number of threads according to the second step length rule, and determine the second candidate number of threads according to the termination condition; determine the optimal number of threads according to the first candidate number of threads and the second candidate number of threads, thereby improving the accuracy and comprehensiveness of the performance test results. The system is performance tested according to the optimal number of threads to obtain the third performance test data, thereby improving the accuracy of the performance test results. BRIEF DESCRIPTION OF THE DRAWINGS
[0057] Figure 1 A schematic diagram of a performance testing method in one embodiment;
[0058] Figure 2 is a detailed flow chart of a performance testing method in an embodiment;
[0059] Figure 3 is a structural block diagram of a performance testing device in one embodiment;
[0060] Figure 4 FIG. 4 is a diagram showing the internal structure of an electronic device in one embodiment. DETAILED DESCRIPTION
[0061] In order to make the purpose, technical solution and advantages of the present application more clearly understood, the present application is further described in detail below in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain the present application and are not used to limit the present application.
[0062] Embodiment 1
[0063] In one embodiment, Figure 1 , Figure 2 As shown, a performance testing method is provided, the method comprising:
[0064] Determine performance indicators and build test scenarios based on business requirements, user scenarios, and system characteristics;
[0065] Generate a test script based on the performance indicator and the test scenario, wherein the test script includes at least a first step length rule, a second step length rule, and a termination condition, and the thread growth rate in the first step length rule is greater than the thread growth rate in the second step length rule;
[0066] According to the first step length rule, gradually increase the number of threads of the system from 1, and perform performance tests on the system in sequence to obtain first performance test data;
[0067] Determine the number of critical threads and the number of first candidate threads according to the first performance test data and the termination condition;
[0068] According to the second step length rule, gradually increase the number of threads of the system from the critical number of threads, and simultaneously perform performance tests on the system in sequence to obtain second performance test data;
[0069] Determine the second number of candidate threads according to the second performance test data and the termination condition, and determine the optimal number of threads according to the first number of candidate threads and the second number of candidate threads;
[0070] A performance test is performed on the system according to the optimal number of threads to obtain third performance test data.
[0071] In a specific embodiment, the business requirements refer to business objectives and functional requirements that the system needs to meet, etc. These requirements usually come from requirement documents or meeting discussions of stakeholders such as customers, product managers, and business analysts.
[0072] In a specific embodiment, the user scenario refers to various situations and operation sequences that users may encounter when actually using the system. These scenarios are usually based on user stories, use case descriptions, or actual observed user behaviors. For example: a typical business process, a series of operation steps required for users to complete a business goal, such as online shopping, order processing, user registration, etc.; a peak load scenario, how users interact with the system when the system load reaches a peak (such as during holidays and promotional activities); an abnormal scenario, user behavior when the system faces abnormal situations, such as network interruptions, server downtime, etc.; a mixed scenario, a mixture of multiple typical business processes and abnormal scenarios to simulate user behavior in a real environment.
[0073] In a specific embodiment, the system characteristics refer to the technical characteristics and architectural features of the system itself, which are usually closely related to the system's architectural design, technology selection, deployment method, etc.
[0074] In a specific embodiment, the performance indicators include, but are not limited to, response time, throughput (number of transactions processed per second), number of concurrent users, and resource utilization.
[0075] In a specific embodiment, the number of threads may also be increased starting from the minimum number of threads in the system according to the first step length rule.
[0076] Specifically, the number of threads is increased from 1 according to the first step length rule, and the number of critical threads and the number of first candidate threads are determined according to the termination condition; the number of threads is increased from the critical number of threads according to the second step length rule, and the number of second candidate threads is determined according to the termination condition; the optimal number of threads is determined according to the first candidate number of threads and the second candidate number of threads, thereby improving the accuracy and comprehensiveness of the performance test results. The system is performance tested according to the optimal number of threads to obtain the third performance test data, thereby improving the accuracy of the performance test results.
[0077] In one embodiment, determining the number of critical threads and the number of first candidate threads according to the first performance test data and the termination condition includes:
[0078] Sorting the first performance test data in order of the number of threads from small to large, and comparing each first performance test data with the termination condition in turn;
[0079] The number of threads corresponding to the first performance test data that first meets the termination condition is used as the first candidate thread number;
[0080] According to the first number of candidate threads and the first step length rule, the number of threads previous to the first number of candidate threads is obtained, and the number of threads previous to the first number of candidate threads is used as the critical number of threads.
[0081] Specifically, the critical number of threads is determined according to the first step length rule with a faster thread growth rate, and the critical number of threads is used as the starting value of the second step length rule, which reduces system pressure and improves the speed of performance testing.
[0082] In one embodiment, determining the second number of candidate threads according to the second performance test data and the termination condition, and determining the optimal number of threads according to the first number of candidate threads and the second number of candidate threads, includes:
[0083] Sorting the second performance test data in order of the number of threads from small to large, and comparing each second performance test data with the termination condition in turn;
[0084] The number of threads corresponding to the first second performance test data satisfying the termination condition is used as the number of second candidate threads;
[0085] Comparing the number of the first candidate threads with the number of the second candidate threads;
[0086] In response to the first candidate thread number being greater than the second candidate thread number, the first candidate thread number is determined to be an optimal thread number.
[0087] Specifically, by comparing the number of the first candidate threads and the number of the second candidate threads, the optimal number of threads is determined so that the subsequent system is in a limit state during performance testing, thereby improving the accuracy of the performance testing.
[0088] In one embodiment, a performance test is performed on the system according to the optimal number of threads to obtain third performance test data, including:
[0089] Repeating the performance test on the system with the optimal number of threads according to the test times in the test script to obtain fourth performance test data;
[0090] Sorting the fourth performance test data in order from large to small or from small to large;
[0091] According to the sorting result, remove the first fourth performance test data and the last fourth performance test data, and calculate the first average value of the remaining fourth performance test data;
[0092] The first average value is used as the third performance test data.
[0093] Specifically, by removing the maximum fourth performance test data and the minimum fourth performance test data, the third performance test data can better represent the average situation of the fourth performance test data.
[0094] In one embodiment, before sorting the fourth performance test data in order from large to small or from small to large, the method further includes:
[0095] Calculating a second average value of the fourth performance test data, and calculating a difference between each fourth performance test data and the second average value;
[0096] Setting an error threshold, and comparing the difference value corresponding to each fourth performance test data with the error threshold;
[0097] In response to the difference corresponding to the fourth performance test data being greater than the error threshold, the fourth performance test data is determined to be abnormal data, and the abnormal data is deleted.
[0098] In a specific embodiment, the error threshold may be set to 10% of the second average value.
[0099] Specifically, by removing abnormal data, the accuracy of the third performance test data is ensured.
[0100] In one embodiment, the first performance test data satisfying the termination condition is obtained by:
[0101] Compare various types of data in each first performance test data with thresholds of corresponding types in the termination condition, wherein the various types of data include memory occupancy, disk load percentage, and bandwidth usage, and the corresponding types of thresholds include memory occupancy percentage threshold, disk load percentage threshold, and bandwidth usage percentage threshold;
[0102] In response to any type of data in the first performance test data exceeding a threshold of a corresponding type in the termination condition, it is determined that the first performance test data satisfies the termination condition.
[0103] In one embodiment, generating a test script based on the performance indicator and the test scenario includes:
[0104] Generate a test plan based on the performance indicators and test scenarios, and generate the test script based on the test plan, wherein the test plan includes a performance testing tool;
[0105] The performance testing tool is obtained in the following way:
[0106] Acquire a performance testing tool framework written in a target programming language, wherein the performance testing tool framework includes a first test class that supports the performance test;
[0107] Using a first conversion method, converting the programming language of the first base class in the first test class into another programming language to obtain a second base class, wherein the first conversion method is a conversion method with a feature of supporting cross-language polymorphism, and the first base class refers to a core class for performance testing in the first test class;
[0108] Using a second conversion method, converting the programming language of the first control class in the first test class into the other programming language to obtain a second control class, wherein the second conversion method is different from the first conversion method, and the first control class refers to a class in the first test class that controls performance test parameters;
[0109] Based on the second base class, obtaining a derived class written in the other programming language;
[0110] A performance testing tool is generated according to the derived class and the second test class, wherein the second test class includes the second base class and the second control class.
[0111] Specifically, by converting the programming language of the performance testing tool framework, we can not only obtain performance testing tools of other programming languages, but also break the constraints of programming languages, allowing the performance testing tools to include highly flexible derived classes, thereby enhancing the polymorphism of the performance testing tools and supporting the customization of the performance testing tools.
[0112] In one embodiment, the method further comprises:
[0113] Acquiring test task information for performing performance testing on the system;
[0114] Based on the test task information, acquiring test data for executing the performance test, and determining a test type corresponding to each test data according to the test data;
[0115] Based on the test task information, determine the quantity of the test data and the task type corresponding to the test task information, and generate a parameter template matching the task type, wherein the quantity of the parameter template is consistent with the quantity of the test data;
[0116] Assign values to the numbered parameter items in each parameter template, where the numbered parameter items in each parameter template are unique;
[0117] Establishing an association relationship between the test data and the parameter template, and using the numbered parameter item in the parameter template associated with the test data as the data number of the test data;
[0118] Determine, according to the test type, a bit value of a parameter item related to the test type in a parameter template corresponding to the test data;
[0119] Importing each bit value into the parameter template to generate test parameters for the test data;
[0120] Generate a test case based on the test data and test parameters corresponding to the test data;
[0121] The system is subjected to performance testing through test cases corresponding to all test data.
[0122] Specifically, by generating test parameters based on test tasks and parameterizing test data, the parameter items of test parameters are enriched, making test cases closer to reality and ensuring the credibility of performance test results. At the same time, by automatically configuring the test parameters of test data, parameterization is made simple, fast and efficient, reducing the preparation cost of performance testing and saving system resources.
[0123] It should be understood that although Figure 1 , Figure 2 The steps in the flowchart are shown in sequence as indicated by the arrows, but these steps are not necessarily executed in the order indicated by the arrows. Unless otherwise specified in this document, there is no strict order restriction for the execution of these steps, and these steps can be executed in other orders. Moreover, Figure 1 , Figure 2 At least part of the steps may include multiple sub-steps or multiple stages. These sub-steps or stages are not necessarily executed at the same time, but can be executed at different times. The execution order of these sub-steps or stages is not necessarily sequential, but can be executed in turn or alternately with other steps or at least part of the sub-steps or stages of other steps.
[0124] Embodiment 2
[0125] In one embodiment, Figure 3 As shown, a performance testing device is provided, the device comprising:
[0126] A first determination module, the first determination module is used to determine performance indicators and build test scenarios according to business requirements, user scenarios and system characteristics;
[0127] A generation module, the generation module is used to generate a test script based on the performance indicator and the test scenario, wherein the test script includes at least a first step length rule, a second step length rule and a termination condition, and the thread growth rate in the first step length rule is greater than the thread growth rate in the second step length rule;
[0128] A first increasing module, the first increasing module is used to gradually increase the number of threads of the system starting from 1 according to the first step length rule;
[0129] A first test module, the first test module is used to perform performance tests on the system in sequence to obtain first performance test data;
[0130] a second determination module, the second determination module being used to determine the number of critical threads and the number of first candidate threads according to the first performance test data and a termination condition;
[0131] A second increasing module, the second increasing module is used to gradually increase the number of threads of the system starting from the critical number of threads according to the second step rule;
[0132] A second test module, the second test module is used to perform performance tests on the system in sequence to obtain second performance test data;
[0133] a third determination module, the third determination module being used to determine the second number of candidate threads according to the second performance test data and the termination condition, and to determine the optimal number of threads according to the first number of candidate threads and the second number of candidate threads;
[0134] The third testing module is used to perform a performance test on the system according to the optimal number of threads to obtain third performance testing data.
[0135] In one embodiment, the second determination module is used to determine the number of critical threads and the number of first candidate threads according to the first performance test data and the termination condition, including:
[0136] Sorting the first performance test data in order of the number of threads from small to large, and comparing each first performance test data with the termination condition in turn;
[0137] The number of threads corresponding to the first performance test data that first meets the termination condition is used as the first candidate thread number;
[0138] According to the first number of candidate threads and the first step length rule, the number of threads previous to the first number of candidate threads is obtained, and the number of threads previous to the first number of candidate threads is used as the critical number of threads.
[0139] In one embodiment, the third determination module is used to determine the second number of candidate threads according to the second performance test data and the termination condition, and determine the optimal number of threads according to the first number of candidate threads and the second number of candidate threads, including:
[0140] Sorting the second performance test data in order of the number of threads from small to large, and comparing each second performance test data with the termination condition in turn;
[0141] The number of threads corresponding to the first second performance test data satisfying the termination condition is used as the number of second candidate threads;
[0142] Comparing the number of the first candidate threads with the number of the second candidate threads;
[0143] In response to the first candidate thread number being greater than the second candidate thread number, the first candidate thread number is determined to be an optimal thread number.
[0144] In one embodiment, the third test module is used to perform a performance test on the system according to the optimal number of threads to obtain third performance test data, including:
[0145] Repeating the performance test on the system with the optimal number of threads according to the test times in the test script to obtain fourth performance test data;
[0146] Sorting the fourth performance test data in order from large to small or from small to large;
[0147] According to the sorting result, remove the first fourth performance test data and the last fourth performance test data, and calculate the first average value of the remaining fourth performance test data;
[0148] The first average value is used as the third performance test data.
[0149] In one embodiment, before the third test module is used to sort the fourth performance test data in order from large to small or from small to large, it also includes:
[0150] Calculating a second average value of the fourth performance test data, and calculating a difference between each fourth performance test data and the second average value;
[0151] Setting an error threshold, and comparing the difference value corresponding to each fourth performance test data with the error threshold;
[0152] In response to the difference corresponding to the fourth performance test data being greater than the error threshold, the fourth performance test data is determined to be abnormal data, and the abnormal data is deleted.
[0153] In one embodiment, the first performance test data satisfying the termination condition in the second determination module is obtained by the following units:
[0154] A comparison unit, the comparison unit is used to compare various types of data in each first performance test data with thresholds of corresponding types in the termination condition, wherein the various types of data include memory occupancy, disk load percentage, and bandwidth usage, and the corresponding types of thresholds include memory occupancy percentage threshold, disk load percentage threshold, and bandwidth usage percentage threshold;
[0155] A determination unit, wherein the determination unit is configured to determine that the first performance test data satisfies the termination condition in response to any type of data in the first performance test data exceeding a threshold of a corresponding type in the termination condition.
[0156] In one embodiment, the generating module is used to generate a test script based on the performance indicator and the test scenario, including:
[0157] Generate a test plan based on the performance indicators and test scenarios, and generate the test script based on the test plan, wherein the test plan includes a performance testing tool;
[0158] The performance testing tool in the generation module is obtained through the following units:
[0159] A first acquisition unit, the first acquisition unit is used to acquire a performance testing tool framework written in a target programming language, wherein the performance testing tool framework includes a first test class that supports the performance test;
[0160] a first conversion unit, the first conversion unit being used to convert the programming language of the first base class in the first test class into another programming language by adopting a first conversion method to obtain a second base class, wherein the first conversion method is a conversion method having a feature of supporting cross-language polymorphism, and the first base class refers to a core class for performance testing in the first test class;
[0161] a second conversion unit, the second conversion unit being used to convert the programming language of the first control class in the first test class into the other programming language by adopting a second conversion method to obtain a second control class, wherein the second conversion method is different from the first conversion method, and the first control class refers to a class in the first test class that controls performance test parameters;
[0162] a second acquisition unit, the second acquisition unit being configured to acquire, based on the second base class, a derived class written in the other programming language;
[0163] A generating unit, wherein the generating unit is used to generate a performance testing tool according to the derived class and the second test class, wherein the second test class includes the second base class and the second control class.
[0164] For the specific definition of the performance testing device, please refer to the definition of the performance testing method above, which will not be repeated here. Each module in the above-mentioned performance testing device can be implemented in whole or in part by software, hardware and a combination thereof. The above-mentioned modules can be embedded in or independent of the processor in the electronic device in the form of hardware, or can be stored in the memory of the electronic device in the form of software, so that the processor can call and execute the operations corresponding to the above modules.
[0165] Embodiment 3
[0166] In one embodiment, an electronic device is provided, including a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor implements the following steps when executing the computer program:
[0167] Determine performance indicators and build test scenarios based on business requirements, user scenarios, and system characteristics;
[0168] Generate a test script based on the performance indicator and the test scenario, wherein the test script includes at least a first step length rule, a second step length rule, and a termination condition, and the thread growth rate in the first step length rule is greater than the thread growth rate in the second step length rule;
[0169] According to the first step length rule, gradually increase the number of threads of the system from 1, and perform performance tests on the system in sequence to obtain first performance test data;
[0170] Determine the number of critical threads and the number of first candidate threads according to the first performance test data and the termination condition;
[0171] According to the second step length rule, gradually increase the number of threads of the system from the critical number of threads, and simultaneously perform performance tests on the system in sequence to obtain second performance test data;
[0172] Determine the second number of candidate threads according to the second performance test data and the termination condition, and determine the optimal number of threads according to the first number of candidate threads and the second number of candidate threads;
[0173] A performance test is performed on the system according to the optimal number of threads to obtain third performance test data.
[0174] When the program instructions are read and executed by the one or more processors, the program instructions may also perform operations corresponding to the steps in the above method embodiments, and the above description may be referred to, which will not be repeated here. Figure 4, which exemplarily shows the architecture of the electronic device, which may specifically include a processor 410, a video display adapter 411, a disk drive 412, an input / output interface 413, a network interface 414, and a memory 420. The processor 410, the video display adapter 411, the disk drive 412, the input / output interface 413, the network interface 414, and the memory 420 may be communicatively connected via a communication bus 430.
[0175] Among them, the processor 410 can be implemented by a general-purpose central processing unit (CPU), a microprocessor, an application specific integrated circuit (ASIC), or one or more integrated circuits, and is used to execute relevant programs to implement the technical solution provided in this application.
[0176] The memory 420 can be implemented in the form of a read-only memory (ROM), a random access memory (RAM), a static storage device, a dynamic storage device, etc. The memory 420 can store an operating system 421 for controlling the operation of the electronic device 400, and a basic input and output system (BIOS) 422 for controlling the low-level operation of the electronic device 400. In addition, a web browser 423, a data storage manager 424, and an icon font processing system 425, etc. can also be stored. The above-mentioned icon font processing system 425 can be an application program that specifically implements the operations of the aforementioned steps in the embodiment of the present application. In short, when the technical solution provided in the present application is implemented by software or firmware, the relevant program code is stored in the memory 420 and is called and executed by the processor 410.
[0177] The input / output interface 413 is used to connect the input / output module to realize information input and output. The input / output module can be configured in the device as a component (not shown in the figure), or it can be externally connected to the device to provide corresponding functions. The input device may include a keyboard, a mouse, a touch screen, a microphone, various sensors, etc., and the output device may include a display, a speaker, a vibrator, an indicator light, etc.
[0178] The network interface 414 is used to connect to a communication module (not shown) to realize communication interaction between the device and other devices. The communication module can realize communication through a wired mode (such as USB, network cable, etc.) or a wireless mode (such as mobile network, WIFI, Bluetooth, etc.).
[0179] The bus 430 comprises a pathway for transmitting information between the various components of the device (eg, the processor 410, the video display adapter 411, the disk drive 412, the input / output interface 413, the network interface 414, and the memory 420).
[0180] In addition, the electronic device 400 can also obtain information on specific collection conditions from the virtual resource object collection condition information database 441 for use in condition judgment, etc.
[0181] It should be noted that, although the electronic device 400 only shows a processor 410, a video display adapter 411, a disk drive 412, an input / output interface 413, a network interface 414, a memory 420, a bus 430, etc., in the specific implementation process, the electronic device may also include other components necessary for normal operation. In addition, it can be understood by those skilled in the art that the above device may also only include components necessary for implementing the solution of the present application, and does not necessarily include all the components shown in the figure.
[0182] It can be known from the description of the above implementation methods that those skilled in the art can clearly understand that the present application can be implemented by means of software plus a necessary general hardware platform. Based on such an understanding, the technical solution of the present application can be essentially or partly contributed to the prior art in the form of a software product, which can be stored in a storage medium such as ROM / RAM, a disk, an optical disk, etc., including several instructions for enabling an electronic device (which can be a personal computer, a cloud server, or a network device, etc.) to execute the methods described in the various embodiments of the present application or certain parts of the embodiments.
[0183] Embodiment 4
[0184] In one embodiment, a computer readable storage medium is provided, on which a computer program is stored, and when the computer program is executed by a processor, the following steps are implemented:
[0185] Determine performance indicators and build test scenarios based on business requirements, user scenarios, and system characteristics;
[0186] Generate a test script based on the performance indicator and the test scenario, wherein the test script includes at least a first step length rule, a second step length rule, and a termination condition, and the thread growth rate in the first step length rule is greater than the thread growth rate in the second step length rule;
[0187] According to the first step length rule, gradually increase the number of threads of the system from 1, and perform performance tests on the system in sequence to obtain first performance test data;
[0188] Determine the number of critical threads and the number of first candidate threads according to the first performance test data and the termination condition;
[0189] According to the second step length rule, gradually increase the number of threads of the system from the critical number of threads, and simultaneously perform performance tests on the system in sequence to obtain second performance test data;
[0190] Determine the second number of candidate threads according to the second performance test data and the termination condition, and determine the optimal number of threads according to the first number of candidate threads and the second number of candidate threads;
[0191] A performance test is performed on the system according to the optimal number of threads to obtain third performance test data.
[0192] Those skilled in the art can understand that all or part of the processes in the above-mentioned embodiment methods can be completed by instructing the relevant hardware through a computer program, and the computer program can be stored in a non-volatile computer-readable storage medium. When the computer program is executed, it can include the processes of the embodiments of the above-mentioned methods. Among them, any reference to memory, storage, database or other media used in the embodiments provided in this application can include non-volatile and / or volatile memory. Non-volatile memory can include read-only memory (ROM), programmable ROM (PROM), electrically programmable ROM (EPROM), electrically erasable programmable ROM (EEPROM) or flash memory. Volatile memory can include random access memory (RAM) or external cache memory. As an illustration and not limitation, RAM is available in many forms, such as static RAM (SRAM), dynamic RAM (DRAM), synchronous DRAM (SDRAM), double data rate SDRAM (DDRSDRAM), enhanced SDRAM (ESDRAM), synchronous link (Synchlink) DRAM (SLDRAM), memory bus (Rambus) direct RAM (RDRAM), direct memory bus dynamic RAM (DRDRAM), and memory bus dynamic RAM (RDRAM).
[0193] The technical features of the above embodiments may be combined arbitrarily. To make the description concise, not all possible combinations of the technical features in the above embodiments are described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of this specification.
[0194] The above-mentioned embodiments only express several implementation methods of the present application, and the descriptions thereof are relatively specific and detailed, but they cannot be understood as limiting the scope of the invention patent. It should be pointed out that, for a person of ordinary skill in the art, several variations and improvements can be made without departing from the concept of the present application, and these all belong to the protection scope of the present application. Therefore, the protection scope of the patent of the present application shall be subject to the attached claims.
[0195] Embodiment 5
[0196] In one embodiment, a computer program product is provided, on which a computer program is stored, and when the computer program is executed by a processor, the following steps are implemented:
[0197] Determine performance indicators and build test scenarios based on business requirements, user scenarios, and system characteristics;
[0198] Generate a test script based on the performance indicator and the test scenario, wherein the test script includes at least a first step length rule, a second step length rule, and a termination condition, and the thread growth rate in the first step length rule is greater than the thread growth rate in the second step length rule;
[0199] According to the first step length rule, gradually increase the number of threads of the system from 1, and perform performance tests on the system in sequence to obtain first performance test data;
[0200] Determine the number of critical threads and the number of first candidate threads according to the first performance test data and the termination condition;
[0201] According to the second step length rule, gradually increase the number of threads of the system from the critical number of threads, and simultaneously perform performance tests on the system in sequence to obtain second performance test data;
[0202] Determine the second number of candidate threads according to the second performance test data and the termination condition, and determine the optimal number of threads according to the first number of candidate threads and the second number of candidate threads;
[0203] A performance test is performed on the system according to the optimal number of threads to obtain third performance test data.
[0204] A person of ordinary skill in the art can understand that all or part of the processes in the above-mentioned embodiment methods can be implemented by instructing related hardware through a computer program. The computer program can be stored in a computer program product. When the computer program is executed, it can include the processes of the embodiments of the above-mentioned methods.
[0205] The technical features of the above embodiments may be combined arbitrarily. To make the description concise, not all possible combinations of the technical features in the above embodiments are described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of this specification.
[0206] The above-mentioned embodiments only express several implementation methods of the present application, and the descriptions thereof are relatively specific and detailed, but they cannot be understood as limiting the scope of the invention patent. It should be pointed out that, for a person of ordinary skill in the art, several variations and improvements can be made without departing from the concept of the present application, and these all belong to the protection scope of the present application. Therefore, the protection scope of the patent of the present application shall be subject to the attached claims.
Claims
1. A performance testing method, It is characterized in that The method comprises: Determine performance indicators and build test scenarios based on business requirements, user scenarios, and system characteristics; Generate a test script based on the performance indicator and the test scenario, wherein the test script includes at least a first step length rule, a second step length rule, and a termination condition, and the thread growth rate in the first step length rule is greater than the thread growth rate in the second step length rule; According to the first step length rule, gradually increase the number of threads of the system from 1, and perform performance tests on the system in sequence to obtain first performance test data; Determine the number of critical threads and the number of first candidate threads according to the first performance test data and the termination condition; According to the second step rule, gradually increase the number of threads of the system starting from the critical number of threads, and simultaneously perform performance tests on the system in sequence to obtain second performance test data; Determine the second number of candidate threads according to the second performance test data and the termination condition, and determine the optimal number of threads according to the first number of candidate threads and the second number of candidate threads; A performance test is performed on the system according to the optimal number of threads to obtain third performance test data.
2. The method according to claim 1, It is characterized in that The determining, according to the first performance test data and the termination condition, the number of critical threads and the number of first candidate threads comprises: Sorting the first performance test data in order of the number of threads from small to large, and comparing each first performance test data with the termination condition in turn; The number of threads corresponding to the first performance test data that first meets the termination condition is used as the first candidate thread number; According to the first number of candidate threads and the first step length rule, the number of threads previous to the first number of candidate threads is obtained, and the number of threads previous to the first number of candidate threads is used as the critical number of threads.
3. The method according to claim 1, It is characterized in that The step of determining the second number of candidate threads according to the second performance test data and the termination condition, and determining the optimal number of threads according to the first number of candidate threads and the second number of candidate threads, comprises: Sorting the second performance test data in order of the number of threads from small to large, and comparing each second performance test data with the termination condition in turn; The number of threads corresponding to the first second performance test data satisfying the termination condition is used as the number of second candidate threads; Comparing the number of the first candidate threads with the number of the second candidate threads; In response to the first candidate thread number being greater than the second candidate thread number, the first candidate thread number is determined to be an optimal thread number.
4. The method according to claim 1, It is characterized in that Performing a performance test on the system according to the optimal number of threads to obtain third performance test data includes: Repeating the performance test on the system with the optimal number of threads according to the test times in the test script to obtain fourth performance test data; Sorting the fourth performance test data in order from large to small or from small to large; According to the sorting result, remove the first fourth performance test data and the last fourth performance test data, and calculate the first average value of the remaining fourth performance test data; The first average value is used as the third performance test data.
5. The method according to claim 4, It is characterized in that Before sorting the fourth performance test data in order from large to small or from small to large, the method further includes: Calculating a second average value of the fourth performance test data, and calculating a difference between each fourth performance test data and the second average value; Setting an error threshold, and comparing the difference value corresponding to each fourth performance test data with the error threshold; In response to the difference corresponding to the fourth performance test data being greater than the error threshold, the fourth performance test data is determined to be abnormal data, and the abnormal data is deleted.
6. The method according to claim 2, It is characterized in that The first performance test data satisfying the termination condition is obtained in the following manner: Compare various types of data in each first performance test data with thresholds of corresponding types in the termination condition, wherein the various types of data include memory occupancy, disk load percentage, and bandwidth usage, and the corresponding types of thresholds include memory occupancy percentage threshold, disk load percentage threshold, and bandwidth usage percentage threshold; In response to any type of data in the first performance test data exceeding a threshold of a corresponding type in the termination condition, it is determined that the first performance test data satisfies the termination condition.
7. The method according to claim 1, It is characterized in that The generating of the test script based on the performance indicator and the test scenario includes: Generate a test plan based on the performance indicators and test scenarios, and generate the test script based on the test plan, wherein the test plan includes a performance testing tool; The performance testing tool is obtained in the following way: Acquire a performance testing tool framework written in a target programming language, wherein the performance testing tool framework includes a first test class that supports the performance test; Using a first conversion method, converting the programming language of the first base class in the first test class into another programming language to obtain a second base class, wherein the first conversion method is a conversion method with a feature of supporting cross-language polymorphism, and the first base class refers to a core class for performance testing in the first test class; Using a second conversion method, converting the programming language of the first control class in the first test class into the other programming language to obtain a second control class, wherein the second conversion method is different from the first conversion method, and the first control class refers to a class in the first test class that controls performance test parameters; Based on the second base class, obtaining a derived class written in the other programming language; A performance testing tool is generated according to the derived class and the second test class, wherein the second test class includes the second base class and the second control class.
8. A performance testing device, It is characterized in that The device comprises: A first determination module, the first determination module is used to determine performance indicators and build test scenarios according to business requirements, user scenarios and system characteristics; A generation module, the generation module is used to generate a test script based on the performance indicator and the test scenario, wherein the test script includes at least a first step length rule, a second step length rule and a termination condition, and the thread growth rate in the first step length rule is greater than the thread growth rate in the second step length rule; A first increasing module, the first increasing module is used to gradually increase the number of threads of the system starting from 1 according to the first step length rule; A first test module, the first test module is used to perform performance tests on the system in sequence to obtain first performance test data; a second determination module, the second determination module being used to determine the number of critical threads and the number of first candidate threads according to the first performance test data and a termination condition; A second increasing module, the second increasing module is used to gradually increase the number of threads of the system starting from the critical number of threads according to the second step rule; A second test module, the second test module is used to perform performance tests on the system in sequence to obtain second performance test data; a third determination module, the third determination module being used to determine the second number of candidate threads according to the second performance test data and the termination condition, and to determine the optimal number of threads according to the first number of candidate threads and the second number of candidate threads; The third testing module is used to perform a performance test on the system according to the optimal number of threads to obtain third performance testing data.
9. An electronic device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, It is characterized in that When the processor executes the computer program, the steps of the method according to any one of claims 1 to 7 are implemented.
10. A computer-readable storage medium having a computer program stored thereon, It is characterized in that When the computer program is executed by a processor, the steps of the method according to any one of claims 1 to 7 are implemented.
