CN110609703B - Performance detection tool implementation method and device, readable storage medium and terminal equipment - Google Patents
Performance detection tool implementation method and device, readable storage medium and terminal equipment Download PDFInfo
- Publication number
- CN110609703B CN110609703B CN201910882724.6A CN201910882724A CN110609703B CN 110609703 B CN110609703 B CN 110609703B CN 201910882724 A CN201910882724 A CN 201910882724A CN 110609703 B CN110609703 B CN 110609703B
- Authority
- CN
- China
- Prior art keywords
- target
- configuration information
- configuration
- file
- plug
- Prior art date
- Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
- Active
Links
- 238000000034 method Methods 0.000 title claims abstract description 162
- 238000001514 detection method Methods 0.000 title claims abstract description 46
- 238000012360 testing method Methods 0.000 claims abstract description 24
- 238000012856 packing Methods 0.000 claims description 9
- 238000012546 transfer Methods 0.000 claims description 7
- 238000013507 mapping Methods 0.000 claims description 5
- 238000004590 computer program Methods 0.000 claims description 3
- 238000006243 chemical reaction Methods 0.000 claims description 2
- 238000010586 diagram Methods 0.000 description 8
- 238000004891 communication Methods 0.000 description 7
- 230000006870 function Effects 0.000 description 5
- 238000004364 calculation method Methods 0.000 description 4
- 238000002347 injection Methods 0.000 description 4
- 239000007924 injection Substances 0.000 description 4
- 239000000243 solution Substances 0.000 description 4
- 238000004422 calculation algorithm Methods 0.000 description 2
- 238000011161 development Methods 0.000 description 2
- 238000012986 modification Methods 0.000 description 2
- 230000004048 modification Effects 0.000 description 2
- 238000004458 analytical method Methods 0.000 description 1
- 230000001419 dependent effect Effects 0.000 description 1
- 238000013461 design Methods 0.000 description 1
- 238000005516 engineering process Methods 0.000 description 1
- 230000010365 information processing Effects 0.000 description 1
- 238000012423 maintenance Methods 0.000 description 1
- 238000011056 performance test Methods 0.000 description 1
- 238000012545 processing Methods 0.000 description 1
- 230000000750 progressive effect Effects 0.000 description 1
Classifications
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F8/00—Arrangements for software engineering
- G06F8/70—Software maintenance or management
- G06F8/71—Version control; Configuration management
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F11/00—Error detection; Error correction; Monitoring
- G06F11/36—Preventing errors by testing or debugging software
- G06F11/3604—Software analysis for verifying properties of programs
- G06F11/3612—Software analysis for verifying properties of programs by runtime analysis
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F11/00—Error detection; Error correction; Monitoring
- G06F11/36—Preventing errors by testing or debugging software
- G06F11/3668—Software testing
- G06F11/3672—Test management
-
- Y—GENERAL TAGGING OF NEW TECHNOLOGICAL DEVELOPMENTS; GENERAL TAGGING OF CROSS-SECTIONAL TECHNOLOGIES SPANNING OVER SEVERAL SECTIONS OF THE IPC; TECHNICAL SUBJECTS COVERED BY FORMER USPC CROSS-REFERENCE ART COLLECTIONS [XRACs] AND DIGESTS
- Y02—TECHNOLOGIES OR APPLICATIONS FOR MITIGATION OR ADAPTATION AGAINST CLIMATE CHANGE
- Y02D—CLIMATE CHANGE MITIGATION TECHNOLOGIES IN INFORMATION AND COMMUNICATION TECHNOLOGIES [ICT], I.E. INFORMATION AND COMMUNICATION TECHNOLOGIES AIMING AT THE REDUCTION OF THEIR OWN ENERGY USE
- Y02D10/00—Energy efficient computing, e.g. low power processors, power management or thermal management
Landscapes
- Engineering & Computer Science (AREA)
- Theoretical Computer Science (AREA)
- General Engineering & Computer Science (AREA)
- Physics & Mathematics (AREA)
- General Physics & Mathematics (AREA)
- Software Systems (AREA)
- Computer Hardware Design (AREA)
- Quality & Reliability (AREA)
- Computer Security & Cryptography (AREA)
- Debugging And Monitoring (AREA)
Abstract
The embodiment of the invention provides a method, a device, a readable storage medium and terminal equipment for realizing a performance detection tool, wherein the method comprises the steps of carrying out information configuration on a file which can be read through a plug-in, reading configuration information through the plug-in, determining a target source code in a source file in a compiling stage, and injecting a preset test code into a byte code file obtained by compiling the target source code; and the configuration information is transferred to the library through the plug-in, so that codes accessing the library can read the configuration information in the running process of the application program to be detected, and the target thread and/or the target process are determined according to the configuration information, and the target thread and/or the target process are detected. Flexible configurability of the performance detection tool is achieved.
Description
Technical Field
The present invention relates to the field of information processing technologies, and in particular, to a method and an apparatus for implementing a performance detection tool, a readable storage medium, and a terminal device.
Background
In the development process of Application (APP), detecting the performance of an Application is one of important links for optimizing the Application. However, the existing performance detection tools are various, but the problem of poor flexibility is generally existed, and the performance detection tools are concretely configured in a way that the detection output is too detailed or not detailed enough, so that the specific requirements of analysts cannot be met.
Therefore, how to improve the flexibility of the performance detection tool is a technical problem to be solved.
Disclosure of Invention
In view of this, embodiments of the present invention provide a method and apparatus for implementing a performance detection tool, a readable storage medium, and a terminal device, so as to improve flexibility of the performance detection tool.
In order to achieve the above object, the embodiment of the present invention provides the following technical solutions:
in a first aspect, a performance detection tool implementation method is provided, including:
the plug-in reads configuration information from a configuration file, wherein the configuration information comprises source file related configuration information and thread and process related configuration information;
the plug-in determines a target source code in a source file of an application program to be detected according to the source file related configuration information, and injects a preset test code into a byte code file compiled by the target source code;
and the plug-in transmits the configuration information to a library so that codes accessing the library can read the configuration information in the running process of the application program to be detected, and a target thread and/or a target process can be determined according to the configuration information so as to detect the target thread and/or the target process.
In a second aspect, there is provided a performance testing tool implementation apparatus, comprising:
the reading module is used for reading configuration information from the configuration file through the plug-in, wherein the configuration information comprises source file related configuration information and thread and process related configuration information;
the determining module is used for determining a target source code in a source file of an application program to be detected according to the source file related configuration information through the plug-in unit, and injecting a preset test code into a byte code file compiled by the target source code;
and the transfer module is used for transferring the configuration information to a library through the plug-in, so that codes accessing the library read the configuration information in the running process of the application program to be detected, and determining a target thread and/or a target process according to the configuration information, and detecting the target thread and/or the target process.
In a third aspect, a terminal device is provided, comprising a memory and a processor;
the memory is used for storing programs;
the processor is configured to execute the program to implement the steps of the performance detection tool implementation method according to any one of the above claims.
In a fourth aspect, there is provided a readable storage medium having stored thereon a computer program, wherein the computer program, when executed by a processor, implements the steps of the performance detection tool implementation method according to any of the preceding claims.
The implementation method, the implementation device, the readable storage medium and the terminal equipment of the performance detection tool provided by the embodiment of the invention are characterized in that information configuration is carried out on a file which can be read through a plug-in, configuration information is read through the plug-in, a target source code is determined in a source file in a compiling stage, and a preset test code is injected into a byte code file obtained by compiling the target source code; and the configuration information is transferred to the library through the plug-in, so that codes accessing the library can read the configuration information in the running process of the application program to be detected, and the target thread and/or the target process are determined according to the configuration information, and the target thread and/or the target process are detected. Flexible configurability of the performance detection tool is achieved.
Drawings
In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings that are required to be used in the embodiments or the description of the prior art will be briefly described below, and it is obvious that the drawings in the following description are only embodiments of the present invention, and that other drawings can be obtained according to the provided drawings without inventive effort for a person skilled in the art.
FIG. 1 is a block diagram of a method for implementing a detection tool according to an embodiment of the present invention;
FIG. 2 is a flowchart of an implementation method of a performance detection tool according to an embodiment of the present invention;
FIG. 3 is a flowchart of one implementation of a plug-in to communicate configuration information to a library provided by an embodiment of the present invention;
FIG. 4 is a schematic structural diagram of a performance testing tool implementation device according to an embodiment of the present invention;
fig. 5 is an exemplary diagram of a hardware structure block diagram of a terminal device according to an embodiment of the present invention.
Detailed Description
The following description of the embodiments of the present invention will be made clearly and completely with reference to the accompanying drawings, in which it is apparent that the embodiments described are only some embodiments of the present invention, but not all embodiments. All other embodiments, which can be made by those skilled in the art based on the embodiments of the invention without making any inventive effort, are intended to be within the scope of the invention.
For the convenience of understanding the solution of the present application, some concepts related to the present application will be explained first:
AOP-Aspect Oriented Programming, a technique for realizing unified maintenance of program functions by precompiled mode and run-time dynamic proxy.
The AOP capability developed in Gradle plug-ins-Android is finally packaged and output into the form of Gradle plug-ins, and is issued to all APP projects for use.
ASM-byte code control framework, a code analysis and modification tool based on Java byte code layer. Is one of the common tools used to implement AOP.
Library-an externally published SDK tool in Android development. The Gradle plug-in can cooperate with the Gradle plug-in, and the Gradle plug-in can insert codes of a use library into source codes of a main project based on ASM.
The basic idea of the implementation method of the performance detection tool disclosed by the application is as follows: the file which can be read through the plug-in interacts with an analyst, so that the analyst can realize the configuration of all configurable items of the performance detection tool through one file; after the configuration of the configuration items is completed, configuration information in the configuration files can be read through the plug-in, on one hand, the plug-in determines target source codes in source files according to the configuration information in a compiling stage, and preset test codes are injected into byte code files obtained by compiling the target source codes; on the other hand, the plug-in unit transmits the configuration information to the library so that the code accessing the library can read the configuration information in the running process of the application program to be detected, and determines a target thread and/or a target process according to the configuration information, and detects the target thread and/or the target process, thereby realizing the flexible and configurable performance detection tool.
In the embodiment of the present application, the configuration items of the performance detection tool are divided into two main categories:
1. a source file related configuration, also referred to as AOP configuration, comprising: source file whitelist configuration, task type configuration, etc. The source file white list is used for defining target source codes which do not need performance detection in the source file. The task type is a target compiling and packing type used for defining the source file to be detected, namely, the performance test is performed on the source file only when the compiling and packing type of the source file is the target compiling and packing type defined by the task type.
2. Thread and process related configurations, i.e., library related configurations, include: target thread configuration, target process configuration, minimum execution time-consuming threshold configuration, etc. The target thread is used for defining threads to be detected; the target process is used for defining a process needing to be detected; the minimum execution time consumption threshold is used for defining a thread and a process which need to output a detection result, namely, for the thread, the execution time consumption of the thread is output only when the execution time consumption of the thread is larger than the minimum execution time consumption threshold, otherwise, the execution time consumption of the thread is not output, and for the process, the execution time consumption of the process is output only when the execution time consumption of the process is larger than the minimum execution time consumption threshold, otherwise, the execution time consumption of the process is not output. In an alternative embodiment, the process and the thread may correspond to different minimum execution time consumption thresholds, i.e. a first minimum execution time consumption threshold is set for the process, and a second minimum execution time consumption threshold is set for the thread, where the first minimum execution time consumption threshold and the second minimum execution time consumption threshold may be the same or different.
In the configuration file, different attribute KEYs KEY are defined for different configuration items respectively, the value of each attribute KEY can be composed of at least one keyword, and space can be used for dividing different keywords. For example, the number of the cells to be processed,
for a source file whitelist configuration, an attribute KEY is defined as MethodTraceByPass. Specific attribute definition examples are as follows: methodTraceByPass = android.support com.facebook okhttp3, in this example, the value of MethodTraceByPass defines three whitelist keywords: android.support, com.facebook and okhttp3. As long as the class name of a certain class file in the source file contains one of the above three package names, the certain class file will not be detected by the performance detection tool, i.e. will not be subjected to test code injection.
For task type configuration, an attribute KEY is defined as MethodTraceTarget. Specific attribute definition examples are as follows: methodtracetarget=debug, in this example, a key debug is defined. As long as the current compile-packed packing type buildType is debug-ended. Test code injection will take place. Other compilation package types (such as release packages) do not make any injection.
For the target thread configuration, the attribute KEY is defined as MethodTraceThread. Specific attribute definition examples are as follows: methodtracethread= main SurfaceDrawThread IOThread, in this example three keywords are defined: main, surfaceDrawThread and IOThread. Only if the thread name contains one of the three keywords, the method is time-consuming to record and output to the detection result file. The execution of other threads is time consuming and can be ignored, i.e., not output. And excessive output is avoided.
For target process configuration, define an attribute KEY: methodTraceProcess. Specific attribute definition examples are as follows: methodtraceprocess=main push, in this example two keywords are defined: main and push. Only if the process name contains one of the two keywords, the recording method consumes time and outputs the time to the detection result file. The execution of other processes is time consuming and can be ignored, i.e., not output. And excessive output is avoided.
Time-consuming threshold configuration for minimum execution. An attribute KEY is defined: methodTraceMinThreshold. Specific attribute definition examples are as follows:
methodtraceminthreshold=10, in this example, a minimum threshold of 10 milliseconds is defined. The method (thread or process) takes more than 10 milliseconds to execute before it is recorded and output to the detection result file. Methods that take less than 10 milliseconds to execute are ignored, i.e., not output. And excessive output is avoided.
Fig. 1 is a schematic diagram of a method for implementing a performance detection tool based on the configuration item according to an embodiment of the present application.
After the configuration of the configuration items is completed, the configuration information in the configuration file is read through the plug-in, on one hand, the plug-in determines a target source code in the source file according to the white list configuration information and the task type configuration information in the compiling stage, and a preset test code is injected into a byte code file compiled by the target source code; on the other hand, the plug-in unit transmits the configuration information to the library so that codes accessing the library can read the line/process configuration information and execute the minimum time-consuming threshold configuration information in the running process of the application program to be detected, and determines a target thread and/or a target process according to the read configuration information, and detects the target thread and/or the target process, thereby realizing flexible and configurable performance detection tools.
Based on the basic idea, an implementation flowchart of the implementation method of the performance detection tool provided in the embodiment of the present application is shown in fig. 2, and may include:
step S21: the plug-in reads configuration information from the configuration file, wherein the configuration information comprises source file related configuration information and thread and process related configuration information.
The source file related configuration information is used for configuration of source file compiling period (usually realized at a PC end), and the thread and process related configuration information is used for configuration of running period (realized at an executable terminal of an application program, such as a mobile phone end) of the application program corresponding to the source file. That is, in the embodiment of the present application, the relevant configuration of the compile time and the run time may be configured in the same configuration file.
The source file related configuration information is used for determining target source codes which need performance detection in the source file. The target source code may be at least one class file in the source file. The thread related configuration information is used for determining a target thread to be detected in the operation stage, and the process related configuration information is used for determining a target process to be detected in the operation stage.
Optionally, the configuration file may be specifically used to perform a source file whitelist configuration, a task type configuration, a target thread configuration, a target process configuration, and a minimum execution time consumption threshold configuration. Wherein,
the source file white list is used for defining target source codes which do not need to be detected in the source file; the task type is used for defining a target compiling and packing type of a source file to be detected; the target thread and the target process are used for defining threads and processes needing to be detected; the minimum execution time threshold is used to define threads and processes that need to output the detection result.
Step S22: the plug-in determines a target source code in a source file of the application program to be detected according to the source file related configuration information, and injects a preset test code into a byte code file compiled by the target source code.
The plug-in can obtain the class name of the class file in the source file through a visit function in the class of the classinitiator, then match the class name with a source file white list to determine whether the class name contains any packet name defined in the white list, if so, the test code is not injected into the class file if the class name does not need to be tested, and if not, the class file is determined to be a target source code to inject the test code into a byte code file compiled by the class file.
The plug-in can obtain a name list of a current task through project. Grad. Startparameter. Task names, for any task name in the name list, task type information carried in the task name is matched with task types defined in task type configuration, and if the task type information carried in the task name is any task type defined in the task type configuration, a task corresponding to the task name is determined to be a target source code, so that test codes are injected into the currently packaged task.
The specific injection of test code is not a focus of this application and may be accomplished with reference to existing implementations and will not be described in detail herein.
Step S23: the plug-in transmits the configuration information to the library so that codes accessing the library can read the configuration information in the running process of the application program to be detected, and the target thread and/or the target process can be determined according to the configuration information, and the target thread and/or the target process can be detected.
For library-related configurations, the ability to dynamically configure within a component library is necessary, but only the plug-in can read the configuration file, but the component library cannot, based on which the present application proposes that the plug-in pass the configuration information to the library.
Alternatively, the code accessing the library may acquire the process name by reading the file contents of the file "/proc/< pid >/cmdline", which is a scheme that externally relies least on acquiring the process name. As a component library, the more simple and better the external use is, the more dependent the external use is, the less easy the component library is to use if the external use needs to provide much information to the component. Thus, the less external dependencies of the component library are better.
Alternatively, the code accessing the library can obtain the thread name very easily through thread.
After the process name is obtained, the obtained process name can be matched with the process name defined in the configuration file, and if the obtained process name is any one of the process names defined in the configuration file, the time-consuming calculation is performed on the process corresponding to the obtained process name. The time-consuming calculation process may specifically be: for each process needing to record time consumption, recording the starting time and the ending time of the process, and determining the difference value between the ending time and the starting time as the running time of the process.
Similarly, after the thread name is obtained, the obtained thread name can be matched with the thread names defined in the configuration file, and if the obtained thread name is any one of the thread names defined in the configuration file, the time-consuming calculation is performed on the thread corresponding to the obtained thread name. The time-consuming calculation process may specifically be: for each thread needing to record time consumption, recording the starting time and the ending time of the thread, and determining the difference value between the ending time and the starting time as the running time of the thread.
For any process with the calculated running time, matching the running time of the process with a minimum execution time threshold corresponding to the process in the configuration information after the running time of the process is calculated, outputting the running time of the process if the running time of the process is greater than the minimum execution time threshold corresponding to the process, otherwise, not outputting the running time of the process.
Similarly, for any thread with the calculated running time, matching the running time of the thread with a minimum execution time consumption threshold corresponding to the thread in the configuration information after the running time of the thread is calculated, if the running time of the thread is greater than the minimum execution time consumption threshold corresponding to the thread, outputting the running time of the thread, otherwise, not outputting the running time of the thread.
According to the implementation method of the performance detection tool disclosed by the application, information configuration is carried out through a file which can be read by a plug-in, configuration information is read by the plug-in, a target source code is determined in a source file in a compiling stage, and a preset test code is injected into a byte code file obtained by compiling the target source code; and the configuration information is transferred to the library through the plug-in, so that codes accessing the library can read the configuration information in the running process of the application program to be detected, and the target thread and/or the target process are determined according to the configuration information, and the target thread and/or the target process are detected. Flexible configurability of the performance detection tool is achieved.
In an alternative embodiment, an implementation flowchart for the plugin to transfer the configuration information to the library is shown in fig. 3, and may include:
step S31: the plug-in converts the configuration information into a string.
Alternatively, the configuration information may be converted into a Json string.
Step S32: the plug-in adds constant attribute in the target class related to the library access in the source file, wherein the value of the constant attribute is the character string, so that the byte code file compiled by the code accessing the library in the source file reads the character string through reflection in the running process of the application program to be detected, and determines a target thread and/or a target process according to the read character string, and detects the target thread and/or the target process.
Alternatively, the target class may be a configuration-related class, such as a Config class.
In an alternative embodiment, an implementation manner of the plug-in to read the configuration information from the configuration file may be:
reading the value of the attribute key from the configuration file by the plug-in according to the built-in attribute key; the attribute keys include source file related attribute keys and thread and process related attribute keys.
In the embodiment of the application, KEYs of all the attributes are preset in the plug-in, and the plug-in can read attribute values in the configuration file one by one according to the attribute KEYs during initialization.
And storing the attribute keys and the corresponding values as configuration information according to the mapping data structure.
Optionally, the attribute keys and corresponding values may be saved into a Map < String, string [ ] ] data structure.
In an alternative embodiment, the plug-in may be a gradle plug-in, and the configuration file may be a gradle.
The gradle plugin can read the attribute values directly in the gradle properties file through project.
In an alternative embodiment, an implementation manner of adding constant attributes in the target class of the source file by the plugin may be:
the plug-in adds constant attributes in the target class of the source file through the bytecode manipulation framework ASM. Specifically, constant attributes may be added to the target class of the source file through the ClassVisittField () function provided by the ASM.
After the constant attribute is injected and generated by the code, the code accessing the library cannot directly read the attribute value because the code is generated after compiling, the character string converted from the configuration information can be read by reflection, and then the character string is converted into the readable configuration information.
Corresponding to the method embodiment, the present application further provides a performance detection tool implementation device, and a schematic structural diagram of the performance detection tool implementation device provided in the embodiment of the present application is shown in fig. 4, which may include:
a reading module 41, a determining module 42 and a transferring module 43; wherein,
the reading module 41 is configured to read configuration information from a configuration file through a plug-in, where the configuration information includes source file related configuration information, and thread and process related configuration information;
the determining module 42 is configured to determine, by using the plug-in, a target source code in a source file of an application to be detected according to the configuration information related to the source file, and inject a preset test code into a bytecode file compiled from the target source code;
the transfer module 43 is configured to transfer the configuration information to a library through the plug-in, so that a code accessing the library reads the configuration information in the running process of the application to be detected, and determines a target thread and/or a target process according to the configuration information, so as to detect the target thread and/or the target process.
According to the performance detection tool implementation device provided by the embodiment of the application, information configuration is carried out on a file which can be read through the plug-in, configuration information is read through the plug-in, an object source code is determined in a source file in a compiling stage, and a preset test code is injected into a byte code file obtained by compiling the object source code; and the configuration information is transferred to the library through the plug-in, so that codes accessing the library can read the configuration information in the running process of the application program to be detected, and the target thread and/or the target process are determined according to the configuration information, and the target thread and/or the target process are detected. Flexible configurability of the performance detection tool is achieved.
In an alternative embodiment, the transfer module 43 includes:
the conversion unit is used for converting the configuration information into a character string through the plug-in;
and the adding unit is used for adding constant attributes in target classes related to library access in the source file through the plug-in, wherein the values of the constant attributes are the character strings, so that the byte code files compiled by codes of the access library in the source file read the character strings through reflection in the running process of the application program to be detected, and determining target threads and/or target processes according to the character strings, and detecting the target threads and/or the target processes.
In an alternative embodiment, the configuration file is used for performing source file white list configuration, task type configuration, target thread configuration, target process configuration and minimum execution time consumption threshold configuration;
the source file white list is used for defining target source codes which do not need to be detected in the source file, and the task type is used for defining target compiling and packing types of the source file which need to be detected; the target thread and the target process are used for defining threads and processes which need to be detected; the minimum execution time consumption threshold is used for defining threads and processes needing to output detection results.
In an alternative embodiment, the reading module 41 comprises:
the reading unit is used for reading the value of the attribute key from the configuration file according to the built-in attribute key through the plug-in; the attribute keys comprise attribute keys related to source files and attribute keys related to threads and processes;
and the storage unit is used for storing the attribute keys and the corresponding values as configuration information according to a mapping data structure.
In an alternative embodiment, the plug-in may be a gradle plug-in, and the configuration file may be a gradle.
In an alternative embodiment, the adding, by the plugin, constant attributes in the object class of the source file may include:
the plug-in adds constant attributes in the target class of the source file through a bytecode manipulation framework ASM.
The embodiment of the invention also provides terminal equipment, which can be provided with the performance detection tool implementation device. An example diagram of a hardware structure block diagram of a terminal device provided by an embodiment of the present invention is shown in fig. 5, and may include:
a processor 1, a communication interface 2, a memory 3 and a communication bus 4;
wherein the processor 1, the communication interface 2 and the memory 3 complete the communication with each other through the communication bus 4;
alternatively, the communication interface 2 may be an interface of a communication module, such as an interface of a GSM module;
the processor 1 may be a central processing unit CPU or a specific integrated circuit ASIC (Application Specific Integrated Circuit) or one or more integrated circuits configured to implement embodiments of the present invention.
The memory 3 may comprise a high-speed RAM memory or may further comprise a non-volatile memory, such as at least one disk memory.
The processor 1 is specifically configured to execute the program stored in the storage 3, so as to implement the following steps:
reading configuration information from a configuration file through a plug-in, wherein the configuration information comprises source file related configuration information and thread and process related configuration information;
determining a target source code in a source file of an application program to be detected according to the source file related configuration information through the plug-in, and injecting a preset test code into a byte code file compiled by the target source code;
and transmitting the configuration information to a library through the plug-in, so that codes accessing the library read the configuration information in the running process of the application program to be detected, determining a target thread and/or a target process according to the configuration information, and detecting the target thread and/or the target process.
Optionally, the processor 1 may be specifically configured to, when transferring the configuration information to the library through the plug-in:
converting the configuration information into a character string through the plug-in;
and adding constant attributes in target classes related to library access in the source file through the plug-in, wherein the values of the constant attributes are the character strings, so that the character strings are read through reflection in the running process of the application program to be detected by a byte code file compiled by codes of an access library in the source file, and a target thread and/or a target process is determined according to the character strings, and the target thread and/or the target process is detected.
Optionally, the configuration file is used for performing source file white list configuration, task type configuration, target thread configuration, target process configuration and minimum execution time consumption threshold configuration;
the source file white list is used for defining target source codes which do not need to be detected in the source file, and the task type is used for defining target compiling and packing types of the source file which need to be detected; the target thread and the target process are used for defining threads and processes which need to be detected; the minimum execution time consumption threshold is used for defining threads and processes needing to output detection results.
Optionally, when the processor 1 reads the configuration information from the configuration file through the plug-in, the method specifically may be used to:
reading the value of the attribute key from the configuration file according to the built-in attribute key through the plug-in; the attribute keys comprise attribute keys related to source files and attribute keys related to threads and processes;
and storing the attribute key and the corresponding value as configuration information according to a mapping data structure.
Optionally, the plug-in is a gradle plug-in, and the configuration file is a gradle.
Optionally, when the processor 1 adds a constant attribute in the target class of the source file through the plug-in, the method specifically may be used to:
and adding constant attributes in the target class of the source file by using the byte code control framework ASM through the plug-in.
The embodiment of the application also provides a readable storage medium, which can store a program suitable for being executed by a processor, the program being configured to:
reading configuration information from a configuration file through a plug-in, wherein the configuration information comprises source file related configuration information and thread and process related configuration information;
determining a target source code in a source file of an application program to be detected according to the source file related configuration information through the plug-in, and injecting a preset test code into a byte code file compiled by the target source code;
and transmitting the configuration information to a library through the plug-in, so that codes accessing the library read the configuration information in the running process of the application program to be detected, determining a target thread and/or a target process according to the configuration information, and detecting the target thread and/or the target process.
Alternatively, the refinement function and the extension function of the program may be described with reference to the above.
In the present specification, each embodiment is described in a progressive manner, and each embodiment is mainly described in a different point from other embodiments, and identical and similar parts between the embodiments are all enough to refer to each other. For the device disclosed in the embodiment, since it corresponds to the method disclosed in the embodiment, the description is relatively simple, and the relevant points refer to the description of the method section.
Those of skill would further appreciate that the various illustrative elements and algorithm steps described in connection with the embodiments disclosed herein may be implemented as electronic hardware, computer software, or combinations of both, and that the various illustrative elements and steps are described above generally in terms of functionality in order to clearly illustrate the interchangeability of hardware and software. Whether such functionality is implemented as hardware or software depends upon the particular application and design constraints imposed on the solution. Skilled artisans may implement the described functionality in varying ways for each particular application, but such implementation decisions should not be interpreted as causing a departure from the scope of the present invention.
The steps of a method or algorithm described in connection with the embodiments disclosed herein may be embodied directly in hardware, in a software module executed by a processor, or in a combination of the two. The software modules may be disposed in Random Access Memory (RAM), memory, read Only Memory (ROM), electrically programmable ROM, electrically erasable programmable ROM, registers, hard disk, a removable disk, a CD-ROM, or any other form of storage medium known in the art.
The previous description of the disclosed embodiments is provided to enable any person skilled in the art to make or use the present invention. Various modifications to these embodiments will be readily apparent to those skilled in the art, and the generic principles defined herein may be applied to other embodiments without departing from the spirit or scope of the invention. Thus, the present invention is not intended to be limited to the embodiments shown herein but is to be accorded the widest scope consistent with the principles and novel features disclosed herein.
Claims (8)
1. A method for implementing a performance testing tool, comprising:
the plug-in reads configuration information from the configuration file; the configuration information comprises source file related configuration information and thread and process related configuration information; the configuration file is used for carrying out source file white list configuration, task type configuration, target thread configuration, target process configuration and minimum execution time consumption threshold configuration; the source file white list is used for defining target source codes which do not need to be detected in the source file, and the task type is used for defining target compiling and packing types of the source file which need to be detected; the target thread is used for defining threads to be detected; the target process is used for defining a process needing to be detected; the minimum execution time consumption threshold is used for defining threads and processes needing to output detection results;
the plug-in determines a target source code in a source file of an application program to be detected according to the source file related configuration information, and injects a preset test code into a byte code file compiled by the target source code;
the plug-in unit converts the configuration information into a character string;
and adding a constant attribute in a target class related to library access in the source file by the plug-in, wherein the value of the constant attribute is the character string, so that a byte code file compiled by a code accessing a library in the source file reads the character string through reflection in the running process of the application program to be detected, and determining a target thread and/or a target process according to the character string, and detecting the target thread and/or the target process.
2. The method of claim 1, wherein the plug-in reading configuration information from a configuration file comprises:
the plug-in reads the value of the attribute key from the configuration file according to the built-in attribute key; the attribute keys comprise attribute keys related to source files and attribute keys related to threads and processes;
and storing the attribute key and the corresponding value as configuration information according to a mapping data structure.
3. The method of claim 1, wherein the plug-in is a gradle plug-in and the configuration file is a gradle.
4. The method of claim 1, wherein the add-in adds constant attributes in a target class of the source file, comprising:
the plug-in adds constant attributes in the target class of the source file through a bytecode manipulation framework ASM.
5. A performance testing tool implementation apparatus, comprising:
the reading module is used for reading the configuration information from the configuration file through the plug-in; the configuration information comprises source file related configuration information and thread and process related configuration information; the configuration file is used for carrying out source file white list configuration, task type configuration, target thread configuration, target process configuration and minimum execution time consumption threshold configuration; the source file white list is used for defining target source codes which do not need to be detected in the source file, and the task type is used for defining target compiling and packing types of the source file which need to be detected; the target thread is used for defining threads to be detected; the target process is used for defining a process needing to be detected; the minimum execution time consumption threshold is used for defining threads and processes needing to output detection results;
the determining module is used for determining a target source code in a source file of an application program to be detected according to the source file related configuration information through the plug-in unit, and injecting a preset test code into a byte code file compiled by the target source code;
the transfer module is used for transferring the configuration information to a library through the plug-in, so that codes accessing the library read the configuration information in the running process of the application program to be detected, and determining a target thread and/or a target process according to the configuration information, and detecting the target thread and/or the target process;
the transfer module includes:
the conversion unit is used for converting the configuration information into a character string through the plug-in;
and the adding unit is used for adding constant attributes in target classes related to library access in the source file through the plug-in, wherein the values of the constant attributes are the character strings, so that the byte code files compiled by codes of the access library in the source file read the character strings through reflection in the running process of the application program to be detected, and determining target threads and/or target processes according to the character strings, and detecting the target threads and/or the target processes.
6. The apparatus of claim 5, wherein the reading module comprises:
the reading unit is used for reading the value of the attribute key from the configuration file according to the built-in attribute key through the plug-in; the attribute keys comprise attribute keys related to source files and attribute keys related to threads and processes;
and the storage unit is used for storing the attribute keys and the corresponding values as configuration information according to a mapping data structure.
7. A terminal device comprising a memory and a processor;
the memory is used for storing programs;
the processor is configured to execute the program to implement the steps of the performance detection tool implementation method according to any one of claims 1 to 4.
8. A readable storage medium having stored thereon a computer program, which, when executed by a processor, implements the steps of the performance detection tool implementation method according to any of claims 1-4.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201910882724.6A CN110609703B (en) | 2019-09-18 | 2019-09-18 | Performance detection tool implementation method and device, readable storage medium and terminal equipment |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201910882724.6A CN110609703B (en) | 2019-09-18 | 2019-09-18 | Performance detection tool implementation method and device, readable storage medium and terminal equipment |
Publications (2)
Publication Number | Publication Date |
---|---|
CN110609703A CN110609703A (en) | 2019-12-24 |
CN110609703B true CN110609703B (en) | 2024-02-23 |
Family
ID=68891737
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN201910882724.6A Active CN110609703B (en) | 2019-09-18 | 2019-09-18 | Performance detection tool implementation method and device, readable storage medium and terminal equipment |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN110609703B (en) |
Families Citing this family (3)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN111931185A (en) * | 2020-08-11 | 2020-11-13 | 深信服科技股份有限公司 | Java anti-serialization vulnerability detection method and component |
CN112114810A (en) * | 2020-08-13 | 2020-12-22 | 浙江大搜车融资租赁有限公司 | Compiling processing method and device |
CN113721920A (en) * | 2021-08-30 | 2021-11-30 | 济南浪潮数据技术有限公司 | Diagnosis method and system of application component, electronic device and storage medium |
Citations (3)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN103297381A (en) * | 2012-02-22 | 2013-09-11 | 阿里巴巴集团控股有限公司 | Service access method based on plugin and system thereof |
CN104156235A (en) * | 2014-07-22 | 2014-11-19 | 北京奇虎科技有限公司 | Browser plugin and/or extension updating method and device |
CN110134400A (en) * | 2019-04-02 | 2019-08-16 | 北京奇艺世纪科技有限公司 | Data capture method, device, electronic equipment and computer readable storage medium |
-
2019
- 2019-09-18 CN CN201910882724.6A patent/CN110609703B/en active Active
Patent Citations (3)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN103297381A (en) * | 2012-02-22 | 2013-09-11 | 阿里巴巴集团控股有限公司 | Service access method based on plugin and system thereof |
CN104156235A (en) * | 2014-07-22 | 2014-11-19 | 北京奇虎科技有限公司 | Browser plugin and/or extension updating method and device |
CN110134400A (en) * | 2019-04-02 | 2019-08-16 | 北京奇艺世纪科技有限公司 | Data capture method, device, electronic equipment and computer readable storage medium |
Also Published As
Publication number | Publication date |
---|---|
CN110609703A (en) | 2019-12-24 |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
Livshits et al. | Reflection analysis for Java | |
Sen et al. | Jalangi: A selective record-replay and dynamic analysis framework for JavaScript | |
US10394694B2 (en) | Unexplored branch search in hybrid fuzz testing of software binaries | |
US8381175B2 (en) | Low-level code rewriter verification | |
US11106437B2 (en) | Lookup table optimization for programming languages that target synchronous digital circuits | |
CN110609703B (en) | Performance detection tool implementation method and device, readable storage medium and terminal equipment | |
US9081586B2 (en) | Systems and methods for customizing optimization/transformation/ processing strategies | |
US9645800B2 (en) | System and method for facilitating static analysis of software applications | |
EP2706459B1 (en) | Apparatus and method for validating a compiler for a reconfigurable processor | |
US9405906B1 (en) | System and method for enhancing static analysis of software applications | |
CN107832059A (en) | Code static analysis method and device based on Makefile | |
US20210103514A1 (en) | Reusable test cases for identifiable patterns | |
CN104050080A (en) | Method and system for debugging linux kernel in user mode | |
US10229273B2 (en) | Identifying components for static analysis of software applications | |
JP6142705B2 (en) | Iterative generation of symbolic test drivers for object-oriented languages | |
Liu et al. | Exploring missed optimizations in webassembly optimizers | |
US11474795B2 (en) | Static enforcement of provable assertions at compile | |
CN114840427A (en) | Code testing and test case generating method and device | |
US20230153109A1 (en) | System and method for analyzing and steering use of third-party libraries | |
CN117873483A (en) | Method and device for compiling intelligent contract, electronic equipment and storage medium | |
CN107451050B (en) | Function acquisition method and device and server | |
CN114510723A (en) | Intelligent contract authority management vulnerability detection method and device | |
CN116775040B (en) | Pile inserting method for realizing code vaccine and application testing method based on code vaccine | |
CN114780952B (en) | Detection method, system and storage medium for sensitive application call scene | |
Livshits et al. | Gulfstream: Incremental static analysis for streaming javascript applications |
Legal Events
Date | Code | Title | Description |
---|---|---|---|
PB01 | Publication | ||
PB01 | Publication | ||
SE01 | Entry into force of request for substantive examination | ||
SE01 | Entry into force of request for substantive examination | ||
GR01 | Patent grant | ||
GR01 | Patent grant |