A performance testing method, device and equipment of a software interface and a medium
By inserting performance analysis code segments into the source code of the software interface and using containers for automated testing, the problems of low efficiency and insufficient accuracy in existing technologies are solved, realizing automated testing and accurate function-level performance analysis of the software interface.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- CHINA POST INFORMATION TECH (BEIJING CO LTD
- Filing Date
- 2022-12-06
- Publication Date
- 2026-05-08
AI Technical Summary
In existing technologies, software interface performance testing requires developers to manually modify the code, resulting in low testing efficiency and inaccurate results, making it impossible to accurately locate performance issues at the specific function level.
The first container inserts performance analysis code segments into the source code of the target software, and the second container performs automated testing to obtain the call information of the target function and generate performance test results at the function level.
It enables automated testing of software interfaces, improving testing efficiency and accuracy, and allowing for detailed identification of performance bottlenecks.
Smart Images

Figure CN115757186B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of software testing technology, and in particular to a method, apparatus, device, and medium for performance testing of software interfaces. Background Technology
[0002] Currently, every system feature undergoes performance testing before going live. However, the performance testing results provided by the performance testing team are at the interface level, only showing the time taken for each interface call, but unable to accurately pinpoint which specific function within the interface is experiencing a performance issue.
[0003] There are many performance analysis tools for Python. However, existing performance analysis techniques usually require developers to manually modify their own code, execute test scripts, and view the performance analysis results. This is time-consuming, labor-intensive, and requires a high level of skill from developers. Summary of the Invention
[0004] This invention provides a method, apparatus, device, and medium for performance testing of software interfaces, thereby achieving automated testing of software interfaces and providing test results at the function level, thus improving testing efficiency and accuracy.
[0005] According to one aspect of the present invention, a performance testing method for a software interface is provided, comprising:
[0006] Obtain the source code to be used corresponding to the interface to be tested in the target software, wherein the source code to be used includes at least one target function;
[0007] The first container inserts a performance analysis code segment into the source code to be used to obtain the corresponding test code; wherein the first container and the second container are deployed on the computer operating system.
[0008] The code to be tested is subjected to performance testing through a second container to determine the call information of the target function during the test, and the target performance test result of the interface to be tested is determined based on the call information.
[0009] According to another aspect of the present invention, a performance testing apparatus for a software interface is provided, comprising:
[0010] The source code acquisition module is used to acquire the source code to be used corresponding to the interface to be tested in the target software, wherein the source code to be used includes at least one target function.
[0011] The source code modification module is used to insert performance analysis code segments into the source code to be used through a first container to obtain the corresponding code to be tested; wherein the first container and the second container are deployed on a computer operating system.
[0012] The target performance testing module is used to perform performance testing on the code under test through a second container, determine the call information of the target function during the testing process, and determine the target performance test result of the interface under test based on the call information.
[0013] According to another aspect of the present invention, an electronic device is provided, the electronic device comprising:
[0014] At least one processor; and
[0015] A memory communicatively connected to the at least one processor; wherein,
[0016] The memory stores a computer program that can be executed by the at least one processor, which enables the at least one processor to perform the performance testing method of the software interface described in any embodiment of the present invention.
[0017] According to another aspect of the present invention, a computer-readable storage medium is provided, the computer-readable storage medium storing computer instructions for causing a processor to execute a performance testing method for a software interface as described in any embodiment of the present invention.
[0018] The technical solution of this invention involves obtaining the source code corresponding to the interface to be tested in the target software, where the source code includes at least one target function; inserting performance analysis code segments into the source code using a first container to obtain the corresponding test code; wherein the first container and a second container are deployed on a computer operating system; and performing performance testing on the test code using the second container to determine the call information of the target function during the testing process, and determining the target performance test result of the interface to be tested based on the call information. This solves the problem that in target software performance testing, developers need to manually modify the code, and the obtained performance test results are at the interface level, leading to low efficiency and inaccuracy. It achieves automated testing of software interfaces, and the test results are at the function level, improving testing efficiency and accuracy.
[0019] It should be understood that the description in this section is not intended to identify key or essential features of the embodiments of the present invention, nor is it intended to limit the scope of the invention. Other features of the invention will become readily apparent from the following description. Attached Figure Description
[0020] To more clearly illustrate the technical solutions in the embodiments of the present invention, the accompanying drawings used in the description of the embodiments will be briefly introduced below. Obviously, the accompanying drawings described below are only some embodiments of the present invention. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0021] Figure 1 This is a flowchart of a software interface performance testing method provided in Embodiment 1 of the present invention;
[0022] Figure 2 This is a performance testing architecture diagram of the software interface applicable to Embodiment 2 of the present invention;
[0023] Figure 3 This is a schematic diagram of the structure of a software interface performance testing device provided in Embodiment 3 of the present invention;
[0024] Figure 4 This is a schematic diagram of the structure of an electronic device provided in Embodiment 4 of the present invention. Detailed Implementation
[0025] To enable those skilled in the art to better understand the present invention, the technical solutions of the present invention will be clearly and completely described below with reference to the accompanying drawings of the embodiments of the present invention. Obviously, the described embodiments are only some embodiments of the present invention, and not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort should fall within the scope of protection of the present invention.
[0026] It should be noted that the terms "first," "second," etc., in the specification, claims, and accompanying drawings of this invention are used to distinguish similar objects and are not necessarily used to describe a specific order or sequence. It should be understood that such data can be interchanged where appropriate so that the embodiments of the invention described herein can be implemented in orders other than those illustrated or described herein. Furthermore, the terms "comprising" and "having," and any variations thereof, are intended to cover a non-exclusive inclusion; for example, a process, method, system, product, or apparatus that comprises a series of steps or units is not necessarily limited to those steps or units explicitly listed, but may include other steps or units not explicitly listed or inherent to such processes, methods, products, or apparatus.
[0027] Before introducing the technical solution of the embodiments of the present invention, the application scenario is first described. The technical solution of the embodiments of the present invention can be used for performance testing of software systems. It is understood that before each software system goes live, performance testing of various functions of the software system must be performed. Currently, performance testing is generally at the interface level, that is, performance testing is performed on the interfaces corresponding to each function to obtain the corresponding test results. However, the test results only know the call duration of each interface, and cannot accurately locate which function in the interface has a performance problem. In addition, before performing interface performance testing, developers need to modify the source code corresponding to the interface, resulting in low efficiency of software performance testing and failure to achieve automated testing. The technical solution of the embodiments of the present invention designs a client and server for interface performance testing. It can download the source code according to the source code address entered by the user in the client and automatically add performance analysis code to the source code to obtain new code to be tested. By testing the code to be tested, the number of calls and runtime of each function in the interface can be obtained. Test results are generated based on the number of calls and runtime, improving the efficiency and accuracy of testing. Performance bottlenecks can be identified based on the number of calls and the time consumed by each function in the interface, so as to optimize the specific code.
[0028] Example 1
[0029] Figure 1 This is a flowchart of a software interface performance testing method provided in Embodiment 1 of the present invention. This embodiment is applicable to the performance testing of software interfaces. The method can be executed by a software interface performance testing device, which can be implemented in hardware and / or software and can be configured in a computer device. Figure 1 As shown, the method includes:
[0030] S110. Obtain the source code to be used corresponding to the interface to be tested in the target software, wherein the source code to be used includes at least one target function.
[0031] The target software can be any software that requires interface performance testing. Target software primarily refers to software or systems developed by developers; for example, target software could be a parcel delivery details recognition software. This is merely an example and not a specific limitation. Correspondingly, implementing the software system's functions requires calling the corresponding interface, which is the interface to be tested corresponding to the target software. The source code to be used refers to the source code written by developers for the interface to be tested, and at least one function included in the source code to be used can serve as the target function.
[0032] Understandably, before performing performance testing on the interface to be tested in the target software, it is necessary to obtain the corresponding source code for that interface. This source code can be found in the storage directory of the source code to be tested. After obtaining the source code, performance analysis is then performed on the interface to be tested.
[0033] Based on the above scheme, the step of obtaining the source code to be used corresponding to the interface to be tested in the target software, wherein the source code to be used includes at least one target function, includes: obtaining the address of the source code to be used input on the display interface of the performance testing client; downloading the source code to be used corresponding to the interface to be tested based on the address of the source code to be used, and storing it in the target directory.
[0034] Among them, the performance testing client refers to a client specifically used for automated testing of software interfaces. The performance testing client can be installed on a computer device. The source code address to be used refers to the Git address of the source code to be used, that is, the storage address of the source code in the version control system. The target directory can be the disk directory of the computer operating system.
[0035] In practical applications, a client and server specifically designed for testing the performance of software interfaces have been developed. Users can edit or import the Git address of the source code of the interface to be tested on the client's display interface. The client can forward the address to the server, which will then download the source code to be tested and store it in the operating system's disk directory.
[0036] S120. Insert the performance analysis code segment into the source code to be used through the first container to obtain the corresponding test code.
[0037] The first container, deployed on a computer operating system, is used to insert performance analysis code segments into the source code to be used. The operating system can be Linux, the performance analysis code refers to CProfile performance analysis code, and the code to be tested refers to the code that needs to be tested. Specifically, after receiving the source code, the first container can add the aforementioned performance analysis code segments to it, and the resulting new code can then be used as the code to be tested.
[0038] Based on the above scheme, the step of inserting performance analysis code segments into the source code to be used through the first container to obtain the corresponding test code includes: determining the syntax tree to be used corresponding to the source code to be used based on the first container and the syntax parsing function; determining the statements to be processed and the functions to be processed in the syntax tree to be used based on the target traversal method; inserting the performance analysis code segments into the code lines adjacent to the statements to be processed and the functions to be processed to obtain the test code corresponding to the source code to be used, and generating a code modification completion identifier.
[0039] Among them, the syntax parsing function can be the ast.parse function, which is used to parse the source code to be used into an AST structure; the target traversal method refers to the walk traversal; the statement to be processed refers to the import statement; the function to be processed is the main function of the source code to be used, which can be the request function; and the code modification flag is used to determine whether the source code to be used has been modified.
[0040] Specifically, in order to automatically and efficiently insert performance analysis code segments into the source code to be used, the first container can call the syntax parsing function to parse the source code to be used, parse it into a syntax tree structure to be used, and traverse the syntax tree by target traversal to determine the position of the statement to be processed and the function to be processed. Then, the performance analysis code is added to the line after the statement to be processed and the line before the main function. In this way, the modification of the source code to be used is completed. The code obtained at this time is the code to be tested, and a code rewriting completion marker can be generated at the same time.
[0041] The advantage of this is that developers only need to enter the address of the source code to be tested on the client, and the source code to be tested can be modified through the first container without the need for manual modification by developers. This reduces the workload of developers and improves the efficiency of performance testing.
[0042] For example, performance analysis code segments can be inserted into the source code to be tested in the following way. It can be understood that Ast is an intermediate product from Python source code to bytecode. With the help of the ast module, the source code structure can be analyzed from the perspective of syntax tree.
[0043] The first step is to obtain the syntax tree. The `ast.parse` method can be used to analyze the service being analyzed into an abstract syntax tree. The `parse` method of `ast` obtains the root node of the `asttree`, `root_node`. The syntax tree can then be traversed through the root node to analyze and modify the Python code.
[0044] The second step is that each node in the syntax tree corresponds to a type under AST. The root node is of type AST.Module. During analysis, the isinstance function can be used to conveniently determine the node type.
[0045] The third step is to traverse the asttree using the walk method. This invention uses ast.walk to traverse the asttree and uses Import and functionDef to determine which lines the import syntax and function definition are on.
[0046] Step 4: Node rewriting. Match each function. When the request function is encountered for the first time, insert the performance analysis code snippet above app.route, and append the necessary imports to the end of the original referenced packages.
[0047] Step 5: Save the above modifications. After executing the current program file, a performance analysis result file will be generated.
[0048] S130. The performance test of the code to be tested is performed through the second container to determine the call information of the target function during the test, and the target performance test result of the interface to be tested is determined based on the call information.
[0049] The second container is deployed on the computer operating system to run the code to be tested. The target performance analysis results can be the performance analysis results of the code to be tested, such as the GPU usage of each code segment in the code to be tested and the performance bottlenecks during the running of the code to be tested.
[0050] Specifically, the code to be tested can be run through a second container, and the call information of the target function in the code to be tested can be determined during the run. Based on the call information, the target performance test result of the interface to be tested can be determined, and the target performance test result can be sent to the performance test client. Through the statistical analysis of the performance test client, the performance test result can be displayed on the display page, so that developers can know which part of the code corresponding to the interface affects the performance and optimize that part of the code.
[0051] Based on the above scheme, the step of performing performance testing on the code under test through a second container, determining the call information of the target function during the test, and determining the target performance test result of the interface under test based on the call information includes: when the modification completion identifier corresponding to the code under test is detected based on the scheduled task script, obtaining the image file corresponding to the second container; starting the second container based on the image file, and performing performance testing on the code under test in the target directory based on the test interface of the second container, so as to determine the call information of the target function during the test.
[0052] The scheduled task script can be used to detect the completion of the modification according to a set period, and the test interface can be the test interface of the second container.
[0053] It's understandable that the code modification completion indicator is primarily used to indicate whether the source code to be used has been modified. Once the modification of the source code to be used is detected as complete, a scheduled task script can be used to start the second container. Specifically, this can involve obtaining the image file of the second container and loading it to start the second container. After starting the second container, it can retrieve the code to be tested from the target directory and further call the test interface of the second container to run the code to be tested, thus determining the call information of each target function during the test execution.
[0054] Based on the above scheme, the step of performing performance testing on the code under test through the second container, determining the call information of the target function during the test, and determining the target performance test result of the interface under test based on the call information includes: performing performance testing on the code under test in the target directory based on the test interface of the second container to determine the number of calls and runtime of the target function in the code under test; generating a target analysis result file based on the number of calls and runtime, and sending the target analysis result file to the performance test client.
[0055] Specifically, the test interface based on the second container runs the code under test in the target directory to determine the number of calls and runtime of the target function in the code under test during the execution. Based on the number of calls and runtime, a target analysis result file is generated and sent to the performance testing client for display. The advantage of this approach is that the second container can automatically run the code under test, obtain the number of calls and runtime of the target function, and generate a target analysis result file based on these data. This not only provides performance analysis testing at the interface level but also provides detailed information on the number of calls and time consumed for each function in the interface, identifying performance bottlenecks. The test results are displayed on the client, eliminating the need for developers to analyze test packets to obtain results, thus lowering the barrier to interface performance analysis and reducing the workload for developers.
[0056] Based on the above scheme, it also includes: performing central processing performance testing on the code to be tested based on the central processing performance test script, and sending the central processing performance test results to the performance test client.
[0057] It is understood that the GPU-level performance test was performed on the interface under test. In this embodiment, a secondary test can also be performed. By calling the corresponding test script, the CPU-level test can be performed on the interface under test. The results of the two performance tests can be combined as the final target performance test result and displayed.
[0058] The technical solution of this invention involves obtaining the source code corresponding to the interface to be tested in the target software, where the source code includes at least one target function; inserting performance analysis code segments into the source code using a first container to obtain the corresponding test code; wherein the first container and a second container are deployed on a computer operating system; and performing performance testing on the test code using the second container to determine the call information of the target function during the testing process, and determining the target performance test result of the interface to be tested based on the call information. This solves the problem that in target software performance testing, developers need to manually modify the code, and the obtained performance test results are at the interface level, leading to low efficiency and inaccuracy. It achieves automated testing of software interfaces, and the test results are at the function level, improving testing efficiency and accuracy.
[0059] Example 2
[0060] Figure 2 This is a performance testing architecture diagram for the software interface applicable to Embodiment 2 of the present invention. This embodiment is a preferred embodiment of the above embodiments, and its specific implementation can be found in the technical solution of this embodiment. Technical terms that are the same as or corresponding to those in the above embodiments will not be repeated here. Figure 2 As shown, the system consists of a front-end and a back-end. The back-end includes a performance analysis container, a service container, and scheduled task scripts.
[0061] The overall architecture is B / S (Browser / Server). The front end provides a web interface for displaying test items and performance analysis results. The back end provides a one-click automated performance analysis service, primarily using Docker container technology and the cProfile performance analysis tool to automate the analysis of performance bottlenecks.
[0062] The backend is deployed with two containers and one shell script:
[0063] Container 1: Also known as the performance analysis container, this is the core of the performance analysis tool. It's responsible for retrieving the Git source code from the git URL provided by the frontend and adding the code snippet to cprofile. It mainly includes the following functionalities:
[0064] The functionalities and descriptions of container 1 are as follows:
[0065] Artifact Import: Receives the gitUrl from the front end and calls an asynchronous method (to retrieve the source code and modify the main function). Source Code Download: Downloads the source code from the git address.
[0066] Source code modification: Modify the source code to include a profile code segment.
[0067] Status query: Based on the scheduling task results, query the current image or container status.
[0068] Second test: navigate to the source code directory and run the Python test script.
[0069] Retrieve Analysis Results: Based on the service container analysis result file, return the front-end analysis results.
[0070] Container 2: Also known as the service container, this is the container started by the project whose bottlenecks are to be analyzed. It mainly includes the following functions:
[0071] The functionalities and descriptions of container 2 are as follows:
[0072] Test Entry Point: Performance testing targets the main service's test entry point. Developers are required to retain test messages in this interface and call the main service.
[0073] Main services: Project services
[0074] Run.sh refers to a scheduled task script. Its main task is to start the service container when it receives a notification that the source code segment to be analyzed has been modified.
[0075] The main processing flow in this implementation is as follows:
[0076] Step 1: The front-end submits the project name and calls the artifact import service in container 1.
[0077] Step 2: After receiving the request, the Container 1 artifact import service returns a 16-bit unique code to inform the WEB that the import was successful; at the same time, it launches an asynchronous thread to execute steps 3 and 4.
[0078] Step 3: Download the source code from Git to the directory containing the 16-bit encoding.
[0079] Step 4: Add the CProfile performance analysis code snippet to the artifact service.
[0080] Step 5: The run.sh scheduled task checks and loads the image of the service to be analyzed, and starts the container of the service to be analyzed, i.e., container 2. At the same time, it makes an HTTP request to the / test interface of container 2.
[0081] Step 6: The front end can view the analysis results through the 16-bit unique code interface.
[0082] Step 7: The front-end can click the "Retest" button to call the / test interface again and view the test results again.
[0083] Key technology: cprofile, a performance analysis technique built into the Python standard library, can show the number of times each function is called and the execution time in the standard output, thereby finding performance bottlenecks.
[0084] This invention mainly encapsulates cprofile-related code segments into independent functions, and combines them with AST to facilitate rewriting the service to be analyzed.
[0085] The following section will provide a detailed explanation of how to traverse the AST and how to add Cprofile performance analysis code snippets to the artifact service.
[0086] Ast traversal: Ast is an intermediate product from Python source code to bytecode. With the help of the ast module, the source code structure can be analyzed from the perspective of syntax tree.
[0087] The first step is to obtain the syntax tree. The `ast.parse` method can be used to analyze the service being analyzed into an abstract syntax tree. The `parse` method of `ast` obtains the root node of the `asttree`, `root_node`. The syntax tree can then be traversed through the root node to analyze and modify the Python code.
[0088] The second step is that each node in the syntax tree corresponds to a type under AST. The root node is of type AST.Module. During analysis, the isinstance function can be used to conveniently determine the node type.
[0089] The third step is to traverse the asttree using the walk method. This invention traverses the asttree using ast.walk and uses Import and functionDef to determine which lines the import syntax and function definition are located on.
[0090] Step 4: Node rewriting. Match each function. When the request function is encountered for the first time, insert the performance analysis code snippet above app.route, and append the necessary imports to the end of the original referenced packages.
[0091] Step 5: Save the above changes.
[0092] Once the current program file is executed, a performance analysis result file will be generated.
[0093] The technical solution of this invention involves obtaining the source code corresponding to the interface to be tested in the target software, where the source code includes at least one target function; inserting performance analysis code segments into the source code using a first container to obtain the corresponding test code; wherein the first container and a second container are deployed on a computer operating system; and performing performance testing on the test code using the second container to determine the call information of the target function during the test, and determining the target performance test result of the interface to be tested based on the call information. This solves the problem that in target software performance testing, developers need to manually modify the code, and the obtained performance test results are at the interface level, leading to low efficiency and inaccuracy. It achieves automated testing of software interfaces, and the test results are at the function level, improving testing efficiency and accuracy. Compared with existing technologies, the technical solution proposed in this invention utilizes Git to obtain the source code, uses AST to analyze the service source code syntax tree structure, adds the cprofile source code segment to the service to be analyzed, uses container technology to start the service and automatically initiate analysis and test requests, and displays the analysis results intuitively on the web, saving developers' time and making it more convenient to use.
[0094] Example 3
[0095] Figure 3 This is a schematic diagram of a software interface performance testing device provided in Embodiment 3 of the present invention. Figure 3 As shown, the device includes:
[0096] The source code acquisition module 310 is used to acquire the source code to be used corresponding to the interface to be tested in the target software, wherein the source code to be used includes at least one target function.
[0097] The source code modification module 320 is used to insert performance analysis code segments into the source code to be used through a first container to obtain the corresponding code to be tested; wherein the first container and the second container are deployed on a computer operating system.
[0098] The target performance testing module 330 is used to perform performance testing on the code to be tested through a second container, determine the call information of the target function during the testing process, and determine the target performance test result of the interface to be tested based on the call information.
[0099] The technical solution of this invention involves obtaining the source code corresponding to the interface to be tested in the target software, where the source code includes at least one target function; inserting performance analysis code segments into the source code using a first container to obtain the corresponding test code; wherein the first container and a second container are deployed on a computer operating system; and performing performance testing on the test code using the second container to determine the call information of the target function during the testing process, and determining the target performance test result of the interface to be tested based on the call information. This solves the problem that in target software performance testing, developers need to manually modify the code, and the obtained performance test results are at the interface level, leading to low efficiency and inaccuracy. It achieves automated testing of software interfaces, and the test results are at the function level, improving testing efficiency and accuracy.
[0100] Optionally, the source code acquisition module 310 includes:
[0101] The source code address acquisition module is used to obtain the source code address to be used that is entered on the display interface of the performance testing client;
[0102] The source code storage module is used to download the source code corresponding to the interface to be tested based on the source code address to be used, and store it in the target directory.
[0103] Optional, source code modification module 320, including:
[0104] The syntax tree building module is used to determine the syntax tree to be used corresponding to the source code to be used, based on the first container and the syntax parsing function.
[0105] The traversal module is used to determine the statements to be processed and the functions to be processed in the syntax tree to be used based on the target traversal method; wherein, the function to be processed is the main function of the source code to be used;
[0106] The modification module is used to insert the performance analysis code segment into the code line adjacent to the statement and function to be processed, to obtain the test code corresponding to the source code to be used, and to generate a code modification completion identifier.
[0107] Optional, the target performance test module 330 includes:
[0108] The image file acquisition module is used to acquire the image file corresponding to the second container when the modification completion identifier corresponding to the code to be tested is detected based on the scheduled task script;
[0109] The testing module is used to start the second container based on the image file and perform performance testing on the code to be tested in the target directory based on the testing interface of the second container, so as to determine the call information of the target function during the test.
[0110] Optional, the target performance test module 330 includes:
[0111] The test information determination module is used to perform performance testing on the code to be tested in the target directory based on the test interface of the second container, so as to determine the number of calls and runtime of the target function in the code to be tested;
[0112] The test result determination module is used to generate a target analysis result file based on the number of calls and runtime, and send the target analysis result file to the performance test client.
[0113] Optionally, the device further includes:
[0114] The central performance testing module is used to perform central processing performance testing on the code under test based on the central processing performance testing script, and send the central processing performance testing results to the performance testing client.
[0115] The software interface performance testing device provided in this embodiment of the invention can execute the software interface performance testing method provided in any embodiment of the invention, and has the corresponding functional modules and beneficial effects of the execution method.
[0116] Example 4
[0117] Figure 4 This is a schematic diagram of an electronic device according to Embodiment 4 of the present invention. The electronic device is intended to represent various forms of digital computers, such as laptop computers, desktop computers, workstations, personal digital assistants, servers, blade servers, mainframe computers, and other suitable computers. The electronic device can also represent various forms of mobile devices, such as personal digital processors, cellular phones, smartphones, wearable devices (such as helmets, glasses, watches, etc.), and other similar computing devices. The components shown herein, their connections and relationships, and their functions are merely illustrative and are not intended to limit the implementation of the invention described and / or claimed herein.
[0118] like Figure 4As shown, the electronic device 10 includes at least one processor 11 and a memory, such as a read-only memory (ROM) 12 or a random access memory (RAM) 13, communicatively connected to the at least one processor 11. The memory stores computer programs executable by the at least one processor. The processor 11 can perform various appropriate actions and processes based on the computer program stored in the ROM 12 or loaded from storage unit 18 into the RAM 13. The RAM 13 can also store various programs and data required for the operation of the electronic device 10. The processor 11, ROM 12, and RAM 13 are interconnected via a bus 14. An input / output (I / O) interface 15 is also connected to the bus 14.
[0119] Multiple components in electronic device 10 are connected to I / O interface 15, including: input unit 16, such as keyboard, mouse, etc.; output unit 17, such as various types of displays, speakers, etc.; storage unit 18, such as disk, optical disk, etc.; and communication unit 19, such as network card, modem, wireless transceiver, etc. Communication unit 19 allows electronic device 10 to exchange information / data with other devices through computer networks such as the Internet and / or various telecommunications networks.
[0120] Processor 11 can be a variety of general-purpose and / or special-purpose processing components with processing and computing capabilities. Some examples of processor 11 include, but are not limited to, a central processing unit (CPU), a graphics processing unit (GPU), various special-purpose artificial intelligence (AI) computing chips, various processors running machine learning model algorithms, a digital signal processor (DSP), and any suitable processor, controller, microcontroller, etc. Processor 11 performs the various methods and processes described above, such as performance testing methods for software interfaces.
[0121] In some embodiments, the performance testing method for the software interface may be implemented as a computer program tangibly contained in a computer-readable storage medium, such as storage unit 18. In some embodiments, part or all of the computer program may be loaded and / or installed on the electronic device 10 via ROM 12 and / or communication unit 19. When the computer program is loaded into RAM 13 and executed by processor 11, one or more steps of the performance testing method for the software interface described above may be performed. Alternatively, in other embodiments, processor 11 may be configured to perform the performance testing method for the software interface by any other suitable means (e.g., by means of firmware).
[0122] Various embodiments of the systems and techniques described above herein can be implemented in digital electronic circuit systems, integrated circuit systems, field-programmable gate arrays (FPGAs), application-specific integrated circuits (ASICs), application-specific standard products (ASSPs), systems-on-a-chip (SoCs), payload-programmable logic devices (CPLDs), computer hardware, firmware, software, and / or combinations thereof. These various embodiments may include implementations in one or more computer programs that can be executed and / or interpreted on a programmable system including at least one programmable processor, which may be a dedicated or general-purpose programmable processor, capable of receiving data and instructions from a storage system, at least one input device, and at least one output device, and transmitting data and instructions to the storage system, the at least one input device, and the at least one output device.
[0123] Computer programs used to implement the methods of the present invention may be written in any combination of one or more programming languages. These computer programs may be provided to a processor of a general-purpose computer, a special-purpose computer, or other programmable data processing device, such that when executed by the processor, the computer programs cause the functions / operations specified in the flowcharts and / or block diagrams to be performed. The computer programs may be executed entirely on a machine, partially on a machine, or as a standalone software package, partially on a machine and partially on a remote machine, or entirely on a remote machine or server.
[0124] In the context of this invention, a computer-readable storage medium can be a tangible medium that may contain or store a computer program for use by or in conjunction with an instruction execution system, apparatus, or device. A computer-readable storage medium may include, but is not limited to, electronic, magnetic, optical, electromagnetic, infrared, or semiconductor systems, apparatus, or devices, or any suitable combination thereof. Alternatively, a computer-readable storage medium may be a machine-readable signal medium. More specific examples of machine-readable storage media include electrical connections based on one or more wires, portable computer disks, hard disks, random access memory (RAM), read-only memory (ROM), erasable programmable read-only memory (EPROM or flash memory), optical fibers, portable compact disk read-only memory (CD-ROM), optical storage devices, magnetic storage devices, or any suitable combination thereof.
[0125] To provide interaction with a user, the systems and techniques described herein can be implemented on an electronic device having: a display device (e.g., a CRT (cathode ray tube) or LCD (liquid crystal display) monitor) for displaying information to the user; and a keyboard and pointing device (e.g., a mouse or trackball) through which the user provides input to the electronic device. Other types of devices can also be used to provide interaction with the user; for example, feedback provided to the user can be any form of sensory feedback (e.g., visual feedback, auditory feedback, or tactile feedback); and input from the user can be received in any form (including sound input, voice input, or tactile input).
[0126] The systems and technologies described herein can be implemented in computing systems that include backend components (e.g., as data servers), or computing systems that include middleware components (e.g., application servers), or computing systems that include frontend components (e.g., user computers with graphical user interfaces or web browsers through which users can interact with implementations of the systems and technologies described herein), or any combination of such backend, middleware, or frontend components. The components of the system can be interconnected via digital data communication of any form or medium (e.g., communication networks). Examples of communication networks include local area networks (LANs), wide area networks (WANs), blockchain networks, and the Internet.
[0127] A computing system can include clients and servers. Clients and servers are generally located far apart and typically interact through communication networks. The client-server relationship is created by computer programs running on the respective computers and having a client-server relationship with each other. The server can be a cloud server, also known as a cloud computing server or cloud host, which is a hosting product within the cloud computing service system to address the shortcomings of traditional physical hosts and VPS services, such as high management difficulty and weak business scalability.
[0128] It should be understood that the various forms of processes shown above can be used, with steps reordered, added, or deleted. For example, the steps described in this invention can be executed in parallel, sequentially, or in different orders, as long as the desired result of the technical solution of this invention can be achieved, and this is not limited herein.
[0129] The specific embodiments described above do not constitute a limitation on the scope of protection of this invention. Those skilled in the art should understand that various modifications, combinations, sub-combinations, and substitutions can be made according to design requirements and other factors. Any modifications, equivalent substitutions, and improvements made within the spirit and principles of this invention should be included within the scope of protection of this invention.
Claims
1. A performance testing method for a software interface, characterized in that, include: Obtain the source code to be used corresponding to the interface to be tested in the target software. The source code to be used includes at least one target function. The process includes: obtaining the address of the source code to be used input on the display interface of the performance testing client; downloading the source code to be used corresponding to the interface to be tested based on the address of the source code to be used, and storing it in the target directory. The first container inserts a performance analysis code segment into the source code to be used to obtain the corresponding test code; wherein the first container and the second container are deployed on the computer operating system. The code to be tested is subjected to performance testing through a second container to determine the call information of the target function during the test, and the target performance test result of the interface to be tested is determined based on the call information. The step of inserting performance analysis code segments into the source code to be used through a first container to obtain the corresponding test code includes: determining the syntax tree to be used corresponding to the source code to be used based on the first container and the syntax parsing function; determining the statements to be processed and the functions to be processed in the syntax tree to be used based on the target traversal method; wherein, the function to be processed is the main function of the source code to be used; inserting the performance analysis code segments into the code lines adjacent to the statements to be processed and the functions to be processed to obtain the test code corresponding to the source code to be used, and generating a code modification completion identifier; wherein, the target traversal method is the walk method, and the performance analysis code refers to Cprofile performance analysis code; The step of performing performance testing on the code under test through a second container, determining the call information of the target function during the test, and determining the target performance test result of the interface under test based on the call information includes: when a modification completion identifier corresponding to the code under test is detected based on a scheduled task script, obtaining an image file corresponding to the second container; starting the second container based on the image file, and performing performance testing on the code under test in the target directory based on the test interface of the second container to determine the call information of the target function during the test; The step of performing performance testing on the code under test through the second container, determining the call information of the target function during the test, and determining the target performance test result of the interface under test based on the call information includes: performing performance testing on the code under test in the target directory based on the test interface of the second container to determine the number of calls and runtime of the target function in the code under test; generating a target analysis result file based on the number of calls and runtime, and sending the target analysis result file to the performance test client.
2. The method according to claim 1, characterized in that, Also includes: The CPU performance of the code under test is tested using a CPU performance test script, and the CPU performance test results are sent to the performance test client.
3. A performance testing device for a software interface, characterized in that, include: The source code acquisition module is used to acquire the source code to be used corresponding to the interface to be tested in the target software, wherein the source code to be used includes at least one target function. The source code modification module is used to insert performance analysis code segments into the source code to be used through a first container to obtain the corresponding code to be tested; wherein the first container and the second container are deployed on a computer operating system. The target performance testing module is used to perform performance testing on the code to be tested through a second container, determine the call information of the target function during the testing process, and determine the target performance test result of the interface to be tested based on the call information. The source code acquisition module includes: The source code address acquisition module is used to obtain the source code address to be used that is entered on the display interface of the performance testing client; The source code storage module is used to download the source code corresponding to the interface to be tested based on the source code address to be used, and store it in the target directory; The source code modification module includes: The syntax tree building module is used to determine the syntax tree to be used corresponding to the source code to be used, based on the first container and the syntax parsing function. The traversal module is used to determine the statements to be processed and the functions to be processed in the syntax tree to be used based on the target traversal method; wherein, the functions to be processed are the main functions of the source code to be used; The modification module is used to insert the performance analysis code segment into the code line adjacent to the statement and function to be processed, to obtain the test code corresponding to the source code to be used, and to generate a code modification completion identifier. The target traversal method is walk mode, and the performance analysis code refers to Cprofile performance analysis code. The target performance testing module includes: The image file acquisition module is used to acquire the image file corresponding to the second container when the modification completion identifier corresponding to the code to be tested is detected based on the scheduled task script; The testing module is used to start the second container based on the image file and perform performance testing on the code to be tested in the target directory based on the testing interface of the second container, so as to determine the call information of the target function during the test. The target performance testing module includes: The test information determination module is used to perform performance testing on the code to be tested in the target directory based on the test interface of the second container, so as to determine the number of calls and runtime of the target function in the code to be tested; The test result determination module is used to generate a target analysis result file based on the number of calls and runtime, and send the target analysis result file to the performance test client.
4. An electronic device, characterized in that, The electronic device includes: At least one processor; and A memory communicatively connected to the at least one processor; wherein, The memory stores a computer program that can be executed by the at least one processor, the computer program being executed by the at least one processor to enable the at least one processor to perform the performance testing method of the software interface according to any one of claims 1-2.
5. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores computer instructions that are used to cause a processor to execute a performance testing method for the software interface of any one of claims 1-2.
Citation Information
Patent Citations
System performance test method, device, apparatus, and storage medium
CN109460365A