Code detection method, device, electronic device and storage medium
By converting the original code into the target terminal executable encoding type and adding detection information during the conversion process, non-invasive code detection is realized, solving the problems of intricacies and low efficiency of code detection in the prior art, and improving the performance hotspot code determine efficiency.
Patent Information
- Application Number
- CN202210059696.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-01-19
- Publication Date
- 2024-12-13
- Estimated Expiration
- 2042-01-19
AI Technical Summary
In the prior art, code detection requires users to insert detection information into the game source code in advance, resulting in high time-consuming and high invasiveness, increasing detection complexity, and making it difficult to effectively determine performance hotspot codes.
By converting the original code information into an encoding type executable by the target terminal and adding code detection information during the conversion process, non-invasive sampling and detection of the code information to be detected is achieved, and direct modification of the source code is avoided, and detection efficiency is improved and flexibility.
It realizes zero-invasion code detection, simplifies the detection process, improves the determination efficiency of performance hotspot code, reduces detection complexity, and supports configurable detection methods, avoiding the difficulty of repeatedly locating performance bottleneck codes.
Smart Images

Figure CN114398285B_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of computer technology, and in particular to a code detection method, device, electronic device and storage medium. Background Art
[0002] With the improvement of mobile phone performance, game picture quality, and the enrichment of mobile game play, mobile game players have higher and higher requirements for the smoothness of the game. Therefore, code detection of game code and identification of performance hotspot codes in game code have become a major node in optimizing game code.
[0003] In the prior art, users are required to insert code detection information into the game source code in advance in order to collect the estimated time-consuming overhead of the performance hotspot code, thereby invading the source code and increasing the complexity of code detection. Summary of the invention
[0004] The present application provides a code detection method, device, electronic device and storage medium, which can isolate source code information and execution code information, thereby achieving zero intrusion on source code information during code detection.
[0005] On the one hand, the present application provides a code detection method, the method comprising:
[0006] Based on the preset code detection configuration information, a configuration detection is performed on the first code information to determine the code information to be detected, where the first code information is the code information corresponding to the original coding type;
[0007] Performing encoding type conversion on the first code information to obtain second code information, where the second code information is code information corresponding to the executable encoding type configured by the target terminal;
[0008] In the process of converting the encoding type of the first code information, adding code detection information to the second code information corresponding to the code information to be detected;
[0009] In the process of executing the second code information, based on the code detection information, code execution information is sampled for the second code information corresponding to the code information to be detected to obtain a code detection result;
[0010] The code detection result is subjected to image conversion processing to obtain a visible image of execution information.
[0011] Another aspect provides a code detection device, the device comprising:
[0012] A configuration detection module, configured to perform configuration detection on the first code information based on preset code detection configuration information to determine the code information to be detected, wherein the first code information is code information corresponding to the original coding type;
[0013] A coding conversion module, used to convert the coding type of the first code information to obtain the second code information, wherein the first code information is the code information corresponding to the original coding type, and the second code information is the code information corresponding to the executable coding type configured by the target terminal;
[0014] A detection information adding module, used for adding code detection information to the second code information corresponding to the code information to be detected during the process of converting the encoding type of the first code information;
[0015] A code detection module, configured to sample code execution information of the second code information corresponding to the code information to be detected based on the code detection information during the execution of the second code information, so as to obtain a code detection result;
[0016] The code detection result processing module is used to perform image conversion processing on the code detection result to obtain a visible image of execution information.
[0017] On the other hand, an electronic device is provided, which includes a processor and a memory, wherein the memory stores at least one instruction or at least one program, and the at least one instruction or the at least one program is loaded and executed by the processor to implement the above-mentioned code detection method.
[0018] On the other hand, a computer-readable storage medium is provided, the storage medium comprising a processor and a memory, the memory storing at least one instruction or at least one program, the at least one instruction or the at least one program being loaded and executed by the processor to implement a code detection method as described above.
[0019] On the other hand, a computer program product is provided, including a computer program, and when the computer program is executed by a processor, the code detection method described above is implemented.
[0020] The present application provides a code detection method, device, electronic device and storage medium, wherein the method determines the code information to be detected in the first code information, and in the process of converting the first code information into the second code information, adds code detection information in the second code information corresponding to the code information to be detected, and in the process of executing the second code information, based on the code detection information, performs code detection on the second code information corresponding to the code information to be detected, and obtains the code detection result. In the process of converting the first code information into the second code information, the method inserts the code detection information into the second code information, and can isolate the source code information and the execution code information, so that the source code information is zero-intruded during code detection. In addition, the method can also determine the code information to be detected from the first code information based on the code detection configuration information, so that the code detection is configurable, so that the code detection based on the zero-intrusion configurable code detection can avoid repeatedly locating the performance hotspot code in the code detection, and improve the efficiency of determining the performance hotspot code. BRIEF DESCRIPTION OF THE DRAWINGS
[0021] In order to more clearly illustrate the embodiments of the present application or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.
[0022] Figure 1 A schematic diagram of an application scenario of a code detection method provided in an embodiment of the present application;
[0023] Figure 2 A flowchart of a code detection method provided in an embodiment of the present application;
[0024] Figure 3 A schematic diagram of traversing first code information to determine a code to be detected in a code detection method provided in an embodiment of the present application;
[0025] Figure 4 A flowchart of adding code detection information to second code information in a code detection method provided in an embodiment of the present application;
[0026] Figure 5 A flowchart of a method for adding time sampling information in a code detection method provided in an embodiment of the present application;
[0027] Figure 6 A flowchart of a method for performing code detection on second code information in a code detection method provided in an embodiment of the present application;
[0028] Figure 7A method flow chart of function calling in a code detection method provided in an embodiment of the present application;
[0029] Figure 8 A schematic diagram of information transmission for converting a code detection result in a code detection method provided in an embodiment of the present application;
[0030] Fig. 9 A schematic diagram of a visualized flame graph in a code detection method provided in an embodiment of the present application;
[0031] Fig.10 A schematic diagram of the structure of a code detection device provided in an embodiment of the present application;
[0032] Fig.11 A schematic diagram of the hardware structure of a device provided in an embodiment of the present application for implementing the method provided in an embodiment of the present application. DETAILED DESCRIPTION
[0033] To make the purpose, technical solutions and advantages of the present application clearer, the present application will be further described in detail below in conjunction with the accompanying drawings. Obviously, the described embodiments are only part of the embodiments of the present application, rather than all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in the field without making creative work are within the scope of protection of the present application.
[0034] In the description of the present application, it should be understood that the terms "first" and "second" are used only for descriptive purposes and should not be understood as indicating or implying relative importance or implicitly indicating the number of technical features indicated. Thus, a feature defined as "first" or "second" may explicitly or implicitly include one or more of the features. Moreover, the terms "first", "second", etc. are applicable to distinguishing similar objects, and need not be used to describe a specific order or sequence. It should be understood that the data used in this way can be interchangeable where appropriate, so that the embodiments of the present application described herein can be implemented in an order other than those illustrated or described herein.
[0035] It is understandable that in the specific implementation of this application, related data such as user information is involved. When the above embodiments of this application are applied to specific products or technologies, user permission or consent is required, and the collection, use and processing of relevant data need to comply with relevant laws, regulations and standards of relevant countries and regions.
[0036] First, the relevant terms involved in the embodiments of the present application are explained as follows:
[0037] Flame graph: The flame graph provides a global view of the program's running time distribution. It lists all call stacks that may cause performance bottlenecks from top to bottom.
[0038] Unity3D: A real-time 3D interactive content creation and operation platform and game engine that can be used to create and operate any real-time interactive 2D and 3D content. Supported platforms include mobile phones, tablets, PCs, game consoles, augmented reality and virtual reality devices.
[0039] C#: It is an object-oriented high-level programming language based on the .net framework launched by Microsoft. It is also the scripting language used by the Unity3D game engine.
[0040] Frames Per Second (FPS): FPS is the number of frames in an animation or video. FPS measures the amount of information used to store and display dynamic video. The more frames per second, the smoother the displayed action will be.
[0041] See also Figure 1 , which shows a schematic diagram of an application scenario of a code detection method provided by an embodiment of the present application, wherein the application scenario includes a mobile terminal 110 and a computer terminal 120, wherein the computer terminal 120 performs encoding type conversion on the first code information to obtain the second code information, adds code detection information to the second code information, and performs code detection on the second code information based on the code detection information during the process of the mobile terminal 110 executing the second code information to obtain a code detection result. Based on the code detection result, the computer terminal 120 performs execution performance analysis on the first code information to determine the performance hotspot code.
[0042] In the embodiment of the present application, the mobile terminal 110 and the computer terminal 120 may include physical devices of the type of smart phones, desktop computers, tablet computers, laptop computers, digital assistants, smart wearable devices, etc., and may also include software running in the physical devices, such as applications, etc. The operating system running on the physical device in the embodiment of the present application may include but is not limited to Android system, IOS system, Linux, Unix, Windows, etc. The mobile terminal 110 is used to execute the second code information to obtain the code detection result, and the computer terminal 120 includes a UI (User Interface) layer. The computer terminal 120 provides the display of the code detection result to the outside through the UI layer. In addition, the code detection result is sent from the mobile terminal 110 to the computer terminal 120 based on the API (Application Programming Interface).
[0043] See also Figure 2 , which shows a code detection method, which can be applied to the mobile terminal side, the method comprising:
[0044] S210. Based on the preset code detection configuration information, the first code information is configured to detect and determine the code information to be detected, where the first code information is the code information corresponding to the original encoding type;
[0045] In some embodiments, the first code information may include code information of multiple original coding types. When performing code detection, the code information in the first code information may be fully detected, or part of the code information in the first code information may be detected. The code detection configuration information may be identification information to be detected corresponding to the code information to be detected, and the identification information to be detected may be a function name. The identification information to be detected in the code detection configuration information is compared with the identification information in the first code information, and the first code information whose identification information matches the identification information to be detected is determined as the code information to be detected.
[0046] The first code information is converted into a coding type to obtain the second code information, and the code detection information is added to the second code information corresponding to the code information to be detected, and the code detection information may not be added to the second code information corresponding to the code information not to be detected. For example, when the code to be detected is the LateUpdate and Update methods of the GameFramework class, and the OnUpdate, OnLateUpdate, and UpdateElse methods of the GameFrameworkWorkFlowDefault class, the above functions can be configured based on the following code detection configuration information:
[0047]
[0048] Based on the above code detection configuration information, the code to be detected in the first code information can be determined.
[0049] In some embodiments, see Figure 3 ,like Figure 3 As shown, the first code information is traversed, and during the traversal process, it is determined whether the first code information currently traversed is the code information to be detected. The identification information to be detected in the code detection configuration information is compared with the identification information corresponding to the first code information currently traversed, and the code information to be detected and the code information not to be detected are determined. In the case that the first code information currently traversed is the code information to be detected, the encoding type of the code information to be detected is converted, and the code detection information is added to the second code information corresponding to the code information to be detected. In the case that the first code information currently traversed is not the code information to be detected, the encoding type of the code information not to be detected is converted.
[0050] Based on the code detection configuration information, the code to be detected can be determined from the first code information, so that the code detection information is only inserted into the second code information corresponding to the code to be detected. While supporting full code detection, the code detection can be freely configured by the user, which increases the diversity of code detection, meets the user's customization needs, and thus improves the user experience.
[0051] S220. Convert the encoding type of the first code information to obtain the second code information, where the second code information is the code information corresponding to the executable encoding type configured by the target terminal;
[0052] In some embodiments, the first code information is source code information, the encoding type corresponding to the source code information is the original encoding type, and the second code information is execution code information, the encoding type corresponding to the execution code information is the executable encoding type configured by the target terminal. The first code information may be C# code information, and the second code information may be C++ code information. An executable document in the target terminal may be generated based on the C++ code information, and the executable document may be run in the target terminal.
[0053] In the application scenario of game code detection, the code information corresponding to the original encoding type can be the script language configured by the preset game engine, for example, the C# code information is the script language used by the Unity3D game engine. Therefore, the C# code information written based on the Unity3D game engine is the source code information of the game, that is, the first code information. The C++ code information is the script language used by the executable document in the mobile terminal. Therefore, the C# code information is converted by the encoding type to obtain the C++ code information, that is, the first code information is converted by the encoding type to obtain the second code information.
[0054] S230. In the process of converting the encoding type of the first code information, adding code detection information to the second code information corresponding to the code information to be detected;
[0055] In some embodiments, code detection information can be added to the second code information based on a preset code detection module, and code detection information will not be added to the first code information. In the case where the first code information includes code information to be detected and code information not to be detected, code detection information is added to the second code information corresponding to the code information to be detected based on the preset code detection module.
[0056] In some embodiments, see Figure 4 The code detection information includes code start detection information and code end detection information. In the process of converting the encoding type of the first code information, adding code detection information to the second code information corresponding to the code information to be detected includes:
[0057] S410. Determine the execution start code and execution end code in the second code information corresponding to the code information to be detected;
[0058] S420. Add code startup detection information in the execution startup code;
[0059] S430. Add code end detection information to the execution end code.
[0060] In some embodiments, when the first code information includes multiple code information of original encoding types, the second code information also includes multiple code information of execution encoding types, the execution start code is the start code of each code information in the second code information when it is executed, and the execution end code is the end code of each code information in the second code information when it is executed. For example, when the code information is a function, the execution start code is the code for entering the function when the function is called to execute the operation corresponding to the function, and the execution end code is the code for exiting the function when the function is called to execute the operation corresponding to the function.
[0061] Code startup detection information can be added in the execution startup code, and code end detection information can be added in the execution end code. The code startup detection information is used to detect the startup information when the code is started, and the code end detection information is used to detect the end information when the code ends. Based on the code startup detection information and the code end detection information, the situation of each code information in the second code information at the time of startup and at the end can be determined, thereby determining the running situation of each code information in the second code information.
[0062] Code start detection information and code end detection information are respectively added to the execution start code and the execution end code in the second code information, so that the operation status of the second code information can be determined according to the situations when the second code information is started and ended, and the detection of the second code information can be completed without affecting the execution of the second code information, thereby improving the accuracy of code information detection.
[0063] In some embodiments, see Figure 5 , the code startup detection information includes the startup time sampling information, and the code startup detection information added in the execution startup code includes:
[0064] S510. Based on the preset time sampling module, the startup time sampling information is inserted into the execution startup code, and the startup time sampling information is used to perform startup time sampling when the second code information starts to execute;
[0065] The code end detection information includes the end time sampling information. The code end detection information added to the execution end code includes:
[0066] S520. Based on the time sampling module, insert end time sampling information into the execution end code, where the end time sampling information is used to perform end time sampling when the second code information ends execution.
[0067] In some embodiments, when the code startup detection information is startup time sampling information, the startup time sampling information can be inserted into the execution startup code based on a preset time sampling module to sample the startup time of the second code information when the second code information starts to execute, and the end time sampling information can be inserted into the execution startup code based on the preset time sampling module to sample the end time of the second code information when the second code information ends execution.
[0068] In some embodiments, the time sampling module may be a profile analysis tool, which may insert detection points at the entry and exit of each code information in the second code information, respectively, and collect information about each code information when it is running based on the detection points. When the code information is a function, the information about each code when it is running may be function call information, instruction information, etc. Based on the profile analysis tool, the startup time sampling information and the end time sampling information are respectively inserted at the entry and exit of each function in the second code information, and the startup time and end time of each function in the second code information may be recorded.
[0069] Based on the time sampling module, the start time sampling information and the end time sampling information are respectively added to the execution start code and the execution end code in the second code information, so that the running status of the second code information is detected based on the running time of the second code information, without involving the code actually executed by the second code information, and thus there is no need to use a customized code version for detection.
[0070] S240. In the process of executing the second code information, based on the code detection information, the code execution information of the second code information corresponding to the code information to be detected is sampled to obtain a code detection result;
[0071] In some embodiments, during the execution of the second code information, the execution state of the second code information can be detected based on the code detection information to obtain a code detection result. The code detection result can be used to represent the execution state information of the second code information.
[0072] In some embodiments, see Figure 6 In the process of executing the second code information, based on the code detection information, the code execution information of the second code information corresponding to the code information to be detected is sampled, and the code detection result obtained includes:
[0073] S610. In the process of executing the second code information, based on the startup time sampling information, the startup time of the second code information corresponding to the code information to be detected is sampled to obtain the startup time information of the second code information;
[0074] S620. In the process of executing the second code information, based on the end time sampling information, the end time of the second code information corresponding to the code information to be detected is sampled to obtain the end time information of the second code information;
[0075] S630. Based on the start time information and the end time information, determine the code execution time of the second code information corresponding to the code information to be detected;
[0076] S640. Use the code execution time as the code detection result.
[0077] In some embodiments, the start time information may be a timestamp when the second code information corresponding to the code information to be detected is started, and the end time information may be a timestamp when the second code information corresponding to the code information to be detected is ended. The timestamp may determine the time point when the second code information corresponding to the code information to be detected is started or ended. The start time information and the end time information are associated with the identification information corresponding to the second code information corresponding to the code information to be detected.
[0078] In some embodiments, when the first code information is fully detected, in the process of executing the second code information, based on the start time sampling information, the start time of each code information in the second code information is sampled to obtain the start time information of each code information in the second code information, and based on the end time sampling information, the end time of each code information in the second code information is sampled to obtain the end time information of each code information in the second code information.
[0079] In some embodiments, when detecting the code to be detected in the first code information, in the process of executing the second code information corresponding to the code information to be detected, based on the start time sampling information, the start time of the second code information corresponding to the code information to be detected is sampled, and the start time information of the second code information corresponding to the code information to be detected can be obtained, and based on the end time sampling information, the end time of the second code information corresponding to the code information to be detected is sampled, and the end time information of the second code information corresponding to the code information to be detected is obtained.
[0080] In some embodiments, based on the start time information and the end time information, the code execution time of the second code information can be determined, thereby determining the code information that occupies the most processor resources in the first code information according to the code execution time of the second code information and the correspondence between the first code information and the second code information.
[0081] In some embodiments, see Figure 7 In the case where the code information is a function, when calling the function, determine whether the function is a function to be detected, and judge whether the function name information matches the preset code detection configuration information. In the case where the function is a function to be detected, in the process of executing the function, based on the start time sampling information and end time sampling information corresponding to the function, record the timestamp when entering and exiting the function respectively, and associate the recorded timestamp with the name information of the function. In the case where the function is not a function to be detected, execute the function logic corresponding to the function, and there is no need to record the start time and end time of the function.
[0082] In some embodiments, when recording the timestamp of entering the function and the timestamp of exiting the function, the mobile terminal can first record the timestamp and the corresponding function name into a circular buffer, and the computer terminal can use a dedicated thread to continuously read the contents of the circular buffer, thereby writing the timestamp and the corresponding function name to the disk of the computer terminal.
[0083] By sampling the start time and the end time of the second code information, the code execution time of the second code information can be obtained. Based on the code execution time, the execution performance of the first code information can be analyzed, thereby improving the efficiency of code detection.
[0084] S250. Perform image conversion processing on the code detection result to obtain a visible image of the execution information.
[0085] In some embodiments, see Figure 8 In the application scenario of game code testing, the second code information can be run on the mobile terminal to obtain the code detection result. The computer terminal obtains the code detection result from the mobile terminal, processes the code detection result, and generates a visual image. The visual image can be a flame graph. See Fig. 9 The flame graph includes blocks of different colors and lengths. The length of the block is used to indicate the code detection result, and the color of the block is used to distinguish different code information. When the code detection result is the code execution time, the longer the block in the flame graph is, the longer the code execution time is. The flame graph can also indicate the call relationship between various code information from top to bottom.
[0086] Based on the code detection results, the first code information is subjected to execution performance analysis to determine the performance hotspot code. The code detection results can be displayed in the form of a flame graph, and then the flame graph is subjected to performance analysis, so as to intuitively display the code detection results, making it easier for users to determine the performance hotspot code.
[0087] In some embodiments, the method further comprises:
[0088] Based on the visual image of the execution information, the execution performance analysis is performed on the first code information to determine the performance hotspot code, which is the code that occupies the processor resources of the target terminal greater than or equal to a preset resource threshold when executed.
[0089] In some embodiments, based on the visual image of the execution information, the execution performance of the first code information can be analyzed to determine the code that occupies the processor resources of the target terminal greater than or equal to a preset resource threshold when executed, that is, the performance hotspot code. Based on the performance hotspot code, the first code information is updated to reduce the occupation of processing resources by the performance hotspot code.
[0090] In some embodiments, when the code detection result is the code execution time, based on the visual image of the execution information, the first code information is subjected to performance analysis, and the performance hotspot code is determined to include:
[0091] Comparing the code execution time of the first code information with the preset execution time;
[0092] The first code information whose code execution time is greater than or equal to the preset execution time is used as the performance hotspot code.
[0093] In some embodiments, after obtaining the code execution time of each code information in the second code information, the code execution time of each code information in the first code information is determined based on the correspondence between the first code information and the second code information, and the code execution time of the first code information is compared with the preset execution time. If the code execution time of the first code information is less than the preset execution time, it means that the processor resources occupied by the first code information during execution are less than the preset resource threshold. If the code execution time of the first code information is greater than or equal to the preset execution time, it means that the processor resources occupied by the first code information during execution are greater than or equal to the preset resource threshold. That is, the first code information whose code execution time is greater than or equal to the preset execution time is a performance hotspot code, which will unreasonably occupy the processor resources of the target terminal.
[0094] Based on the code execution time and the preset execution time, the first code information is subjected to execution performance analysis to determine the performance hotspot code, so as to determine the part of the first code information that affects the code running speed, thereby optimizing the first code information and improving the efficiency of the first code information.
[0095] As an optional embodiment, in the scenario of game code testing, the first code information of the game is obtained, that is, the code information corresponding to the original coding type, and the code information corresponding to the original coding type is the script language configured by the preset game engine, so the first code information is the source code information of the game. The first code information is converted into the coding type to obtain the second code information, and the second code information is the code information corresponding to the executable coding type. The second code information can be run in the target terminal, for example, the game corresponding to the second code information is run on the mobile phone. In the case where the first code information needs to be fully detected, the code detection information is added to the second code information. In the case where part of the first code information needs to be detected, the code information to be detected is first determined from the first code information based on the preset code detection configuration information, and then the code detection information is added to the second code information corresponding to the code information to be detected. Thus, the game can be run in the target terminal, that is, when the second code information is run, the running state of the second code information is detected based on the code detection information, and the code detection result is obtained. The code detection result is image-converted to obtain the visual image of the execution information. And based on the visual image of the execution information, the code with a long execution time in the game can be determined, that is, the code that occupies more game resources, that is, the performance hotspot code is obtained. If these performance hotspot codes are not the codes that must be called when the game is running, the performance hotspot codes can be optimized to improve the smoothness of the game.
[0096] In games where players can manipulate characters, such as open map games or player-versus-player games, user experience is strongly correlated with the fluency of the game. If there are undetected performance hotspot codes in games where players can manipulate characters, the fluency of the game will be reduced. When the fluency of the game is low, it will affect the user's evaluation of the game, leading to user loss. Therefore, the above-mentioned game code detection method can be used to determine the performance hotspot codes that need to be optimized from the codes of these games where players can manipulate characters without changing the game source code. After regularly optimizing the performance hotspot codes, the optimized game code will only need to occupy fewer operating resources when running, so that the game's operating resources can be allocated to the number of frames per second and the picture quality to improve the fluency of the game and improve the user experience.
[0097] The embodiment of the present application provides a code detection method, which determines the code information to be detected in the first code information, and in the process of converting the first code information into the second code information, adds code detection information in the second code information corresponding to the code information to be detected, and in the process of executing the second code information, based on the code detection information, performs code detection on the second code information corresponding to the code information to be detected, and obtains the code detection result. In the process of converting the first code information into the second code information, the method inserts the code detection information into the second code information, which can isolate the source code information and the execution code information, so that the source code information is zero-intruded during code detection. In addition, the method can also determine the code information to be detected from the first code information based on the code detection configuration information, so that the code detection is configurable, so that the code detection based on the zero-intrusion configurable code detection can avoid repeatedly locating the performance hotspot code in the code detection, and improve the efficiency of determining the performance hotspot code.
[0098] The present application also provides a code detection device, see Fig.10 , the device comprises:
[0099] A configuration detection module 1010 is used to perform configuration detection on the first code information based on preset code detection configuration information to determine the code information to be detected, where the first code information is code information corresponding to the original coding type;
[0100] The encoding conversion module 1020 is used to convert the encoding type of the first code information to obtain the second code information, where the first code information is the code information corresponding to the original encoding type, and the second code information is the code information corresponding to the executable encoding type configured by the target terminal;
[0101] A detection information adding module 1030, configured to add code detection information to the second code information corresponding to the code information to be detected during the process of converting the encoding type of the first code information;
[0102] The code detection module 1040 is used to sample the code execution information of the second code information corresponding to the code information to be detected based on the code detection information during the execution of the second code information to obtain a code detection result;
[0103] The code detection result processing module 1050 is used to perform image conversion processing on the code detection result to obtain a visible image of execution information.
[0104] In some embodiments, the code detection information includes code start detection information and code end detection information, and the detection information adding module includes:
[0105] A code-to-be-sampled determining unit, used to determine an execution start code and an execution end code in the second code information corresponding to the code information to be detected;
[0106] A startup detection information adding unit, used to add code startup detection information in the execution startup code;
[0107] The end detection information adding unit is used to add code end detection information to the execution end code.
[0108] In some embodiments, the code startup detection information includes startup time sampling information, and the startup detection information adding unit includes:
[0109] A startup time sampling information insertion unit, used to insert startup time sampling information into the execution startup code based on a preset time sampling module, the startup time sampling information being used to perform startup time sampling when the second code information starts to be executed;
[0110] The code end detection information includes end time sampling information, and the end detection information adding unit includes:
[0111] The end time sampling information inserting unit is used to insert the end time sampling information into the execution end code based on the time sampling module, and the end time sampling information is used to perform end time sampling when the second code information ends execution.
[0112] In some embodiments, the code detection module includes:
[0113] a startup time sampling unit, configured to sample the startup time of the second code information corresponding to the code information to be detected based on the startup time sampling information during the execution of the second code information, so as to obtain the startup time information;
[0114] A start time sampling unit is used to sample the end time of the second code information corresponding to the code information to be detected based on the end time sampling information during the execution of the second code information to obtain the end time information;
[0115] The code execution time determination unit is used to determine the code execution time of the second code information corresponding to the code information to be detected based on the start time information and the end time information, and use the code execution time as the code detection result.
[0116] In some embodiments, the apparatus further comprises:
[0117] The execution performance analysis module is used to perform execution performance analysis on the first code information based on the visual image of the execution information, and determine the performance hotspot code, which is the code that occupies the processor resources of the target terminal greater than or equal to the preset resource threshold when executed.
[0118] In some embodiments, when the code detection result is the code execution time, executing the performance analysis module includes:
[0119] A time comparison unit, used for comparing the code execution time of the first code information with the preset execution time;
[0120] The performance hotspot code determining unit is used to take the first code information whose code execution time is greater than or equal to the preset execution time as the performance hotspot code.
[0121] The device provided in the above embodiment can execute the method provided in any embodiment of the present application, and has the corresponding functional modules and beneficial effects of executing the method. For technical details not described in detail in the above embodiment, please refer to a code detection method provided in any embodiment of the present application.
[0122] This embodiment further provides a computer-readable storage medium, in which computer-executable instructions are stored. The computer-executable instructions are loaded by a processor and execute the above-mentioned code detection method of this embodiment.
[0123] This embodiment also provides a computer program product or a computer program, which includes a computer instruction stored in a computer-readable storage medium. A processor of a computer device reads the computer instruction from the computer-readable storage medium, and the processor executes the computer instruction, so that the computer device executes the method provided in various optional implementations of the above code detection.
[0124] This embodiment further provides an electronic device, which includes a processor and a memory, wherein the memory stores a computer program, and the computer program is suitable for being loaded by the processor and executing the above-mentioned code detection method of this embodiment.
[0125] The electronic device may be a computer terminal, a mobile terminal or a server, and the electronic device may also participate in constituting the device or system provided in the embodiments of the present application. Fig.11 As shown, the computer terminal 11 or mobile terminal 11 may include one or more (1102a, 1102b, ..., 1102n are used to illustrate) processors 1102 (the processor 1102 may include but is not limited to a processing device such as a microprocessor MCU or a programmable logic device FPGA), a memory 1104 for storing data, and a transmission device 1106 for communication functions. In addition, it may also include: a display, an input / output interface (I / O interface), a network interface, a power supply and / or a camera. It can be understood by those skilled in the art that Fig.11 The structure shown is only for illustration and does not limit the structure of the above electronic device. Fig.11 More or fewer components as shown, or with Fig.11 Different configurations are shown.
[0126] It should be noted that the one or more processors 1102 and / or other data processing circuits described above may generally be referred to herein as "data processing circuits". The data processing circuits may be embodied in whole or in part as software, hardware, firmware, or any other combination thereof. In addition, the data processing circuit may be a single independent processing module, or may be fully or partially integrated into any of the other components in the computer terminal 11 or the mobile terminal 11.
[0127] The memory 1104 can be used to store software programs and modules of application software, such as program instructions / data storage devices corresponding to the methods in the embodiments of the present application. The processor 1102 executes the software programs and modules stored in the memory 1104 to perform various functional applications and data processing, that is, to implement the above-mentioned method for generating a temporal behavior capture frame based on a self-attention network. The memory 1104 may include a high-speed random access memory, and may also include a non-volatile memory, such as one or more magnetic storage devices, flash memory, or other non-volatile solid-state memory. In some instances, the memory 1104 may further include a memory remotely arranged relative to the processor 1102, and these remote memories may be connected to the computer terminal 11 or the mobile terminal 11 via a network. Examples of the above-mentioned network include, but are not limited to, the Internet, an intranet, a local area network, a mobile communication network, and combinations thereof.
[0128] The transmission device 1106 is used to receive or send data via a network. The specific example of the above network may include a wireless network provided by a communication provider of the computer terminal 11 or the mobile terminal 11. In one example, the transmission device 1106 includes a network adapter (Network Interface Controller, NIC), which can be connected to other network devices through a base station so as to communicate with the Internet. In one example, the transmission device 1106 can be a radio frequency (Radio Frequency, RF) module, which is used to communicate with the Internet wirelessly.
[0129] The display may be, for example, a touch screen type liquid crystal display (LCD) which may enable a user to interact with a user interface of the computer terminal 11 or the mobile terminal 11 .
[0130] This specification provides method operation steps as described in the embodiments or flow charts, but more or fewer operation steps may be included based on conventional or non-creative labor. The steps and sequence listed in the embodiments are only one way of executing the sequence of many steps and do not represent the only execution sequence. When the actual system or interrupt product is executed, it can be executed in sequence or in parallel according to the method shown in the embodiments or the drawings (for example, in a parallel processor or multi-threaded processing environment).
[0131] The structure shown in this embodiment is only a partial structure related to the scheme of the present application, and does not constitute a limitation on the device to which the scheme of the present application is applied. The specific device may include more or fewer components than shown, or combine certain components, or have different arrangements of components. It should be understood that the method, device, etc. disclosed in this embodiment can be implemented in other ways. For example, the device embodiment described above is only schematic. For example, the division of the modules is only a division of a logical function. There may be other division methods in actual implementation, such as multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be an indirect coupling or communication connection through some interfaces, devices or unit modules.
[0132] Based on this understanding, the technical solution of the present application, or the part that contributes to the prior art, or the whole or part of the technical solution can be embodied in the form of a software product, which is stored in a storage medium and includes several instructions for enabling a computer device (which can be a personal computer, a server, or a network device, etc.) to execute all or part of the steps of the method described in each embodiment of the present application. The aforementioned storage medium includes: U disk, mobile hard disk, read-only memory (ROM, Read-Only Memory), random access memory (RAM, RandomAccess Memory), disk or optical disk, etc., various media that can store program code information.
[0133] Those skilled in the art may further appreciate that the units and algorithm steps of each example described in conjunction with the embodiments disclosed in this specification can be implemented in electronic hardware, computer software, or a combination of the two. In order to clearly illustrate the interchangeability of hardware and software, the composition and steps of each example have been generally described in the above description according to function. Whether these functions are performed in hardware or software depends on the specific application and design constraints of the technical solution. Professional and technical personnel can use different methods to implement the described functions for each specific application, but such implementation should not be considered to be beyond the scope of this application.
[0134] As described above, the above embodiments are only used to illustrate the technical solutions of the present application, rather than to limit them. Although the present application has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that they can still modify the technical solutions described in the aforementioned embodiments, or make equivalent replacements for some of the technical features therein. However, these modifications or replacements do not deviate the essence of the corresponding technical solutions from the spirit and scope of the technical solutions of the embodiments of the present application.
Claims
1. A code detection method, It is characterized in that The method comprises: Based on the preset code detection configuration information, a configuration detection is performed on the first code information to determine the code information to be detected, where the first code information is the code information corresponding to the original coding type; Performing encoding type conversion on the first code information to obtain second code information, where the second code information is code information corresponding to an executable encoding type configured for the target terminal; Traversing the first code information, during the traversal process, determining whether the first code information currently traversed is the code information to be detected; if the first code information currently traversed is the code information to be detected, performing encoding type conversion on the code information to be detected, and adding code detection information to the second code information corresponding to the code information to be detected; if the first code information currently traversed is not code information to be detected, performing encoding type conversion on the code information not to be detected; the first code information and the second code information use different script languages; In the process of executing the second code information, based on the code detection information, code execution information is sampled for the second code information corresponding to the code information to be detected to obtain a code detection result; The code detection result is subjected to image conversion processing to obtain a visible image of execution information.
2. The code detection method according to claim 1, It is characterized in that The code detection information includes code start detection information and code end detection information, and the adding of code detection information to the second code information corresponding to the code information to be detected includes: Determine an execution start code and an execution end code in the second code information corresponding to the code information to be detected; Adding the code startup detection information to the execution startup code; The code end detection information is added to the execution end code.
3. The code detection method according to claim 2, It is characterized in that The code startup detection information includes startup time sampling information, and adding the code startup detection information to the execution startup code includes: Based on a preset time sampling module, inserting the startup time sampling information into the execution startup code, the startup time sampling information is used to perform startup time sampling when the second code information starts to be executed; The code end detection information includes end time sampling information, and the adding of the code end detection information to the execution end code includes: Based on the time sampling module, the end time sampling information is inserted into the execution end code, and the end time sampling information is used to perform end time sampling when the execution of the second code information ends.
4. The code detection method according to claim 3, It is characterized in that In the process of executing the second code information, based on the code detection information, sampling the code execution information of the second code information corresponding to the code information to be detected, and obtaining the code detection result includes: In the process of executing the second code information, based on the startup time sampling information, the startup time of the second code information corresponding to the code information to be detected is sampled to obtain the startup time information; In the process of executing the second code information, based on the end time sampling information, the end time of the second code information corresponding to the code information to be detected is sampled to obtain the end time information; Determine, based on the start time information and the end time information, a code execution time of the second code information corresponding to the code information to be detected; The code execution time is used as the code detection result.
5. The code detection method according to claim 4, It is characterized in that The method further comprises: Based on the visual image of the execution information, the execution performance analysis is performed on the first code information to determine performance hotspot codes, where the performance hotspot codes are codes that occupy processor resources of the target terminal greater than or equal to a preset resource threshold when executed.
6. The code detection method according to claim 5, It is characterized in that In the case where the code detection result is the code execution time, performing execution performance analysis on the first code information based on the visual image of the execution information to determine the performance hotspot code includes: Comparing the code execution time of the first code information with a preset execution time; The first code information whose code execution time is greater than or equal to the preset execution time is used as the performance hotspot code.
7. A code detection device, It is characterized in that The device comprises: A configuration detection module, configured to perform configuration detection on the first code information based on preset code detection configuration information to determine the code information to be detected, wherein the first code information is code information corresponding to the original coding type; A coding conversion module, configured to perform coding type conversion on the first code information to obtain second code information, where the second code information is code information corresponding to an executable coding type configured by a target terminal; A traversal processing module, used to traverse the first code information, and in the process of traversal, determine whether the first code information currently traversed is the code information to be detected; if the first code information currently traversed is the code information to be detected, perform encoding type conversion on the code information to be detected, and add code detection information to the second code information corresponding to the code information to be detected; if the first code information currently traversed is not code information to be detected, perform encoding type conversion on the non-code information to be detected; the first code information and the second code information use different script languages; A code detection module, configured to sample code execution information of the second code information corresponding to the code information to be detected based on the code detection information during the execution of the second code information, so as to obtain a code detection result; The code detection result processing module is used to perform image conversion processing on the code detection result to obtain a visible image of execution information.
8. The code detection device according to claim 7, It is characterized in that The code detection information includes code start detection information and code end detection information, and the traversal processing module includes: A code-to-be-sampled determining unit, configured to determine an execution start code and an execution end code in the second code information corresponding to the code information to be detected; a startup detection information adding unit, configured to add the code startup detection information to the execution startup code; The end detection information adding unit is used to add the code end detection information to the execution end code.
9. The code detection device according to claim 8, It is characterized in that The code startup detection information includes startup time sampling information, and the startup detection information adding unit includes: A startup time sampling information insertion unit, configured to insert the startup time sampling information into the execution startup code based on a preset time sampling module, wherein the startup time sampling information is used to perform startup time sampling when the second code information starts to be executed; The code end detection information includes end time sampling information, and the end detection information adding unit includes: The end time sampling information inserting unit is used to insert the end time sampling information into the execution end code based on the time sampling module, and the end time sampling information is used to perform end time sampling when the second code information ends execution.
10. The code detection device according to claim 9, It is characterized in that The code detection module comprises: a startup time sampling unit, configured to sample the startup time of the second code information corresponding to the code information to be detected based on the startup time sampling information during the execution of the second code information, so as to obtain the startup time information; an end time sampling unit, configured to sample the end time of the second code information corresponding to the code information to be detected based on the end time sampling information during the execution of the second code information, so as to obtain the end time information; A code execution time determination unit is used to determine the code execution time of the second code information corresponding to the code information to be detected based on the start time information and the end time information, and use the code execution time as the code detection result.
11. The code detection device according to claim 10, It is characterized in that The device also includes: The execution performance analysis module is used to perform execution performance analysis on the first code information based on the visual image of the execution information to determine performance hotspot codes, where the performance hotspot codes are codes that occupy processor resources of the target terminal greater than or equal to a preset resource threshold when executed.
12. The code detection device according to claim 11, It is characterized in that In the case where the code detection result is the code execution time, the execution performance analysis module includes: A time comparison unit, used for comparing the code execution time of the first code information with a preset execution time; The performance hotspot code determining unit is used to use the first code information whose code execution time is greater than or equal to the preset execution time as the performance hotspot code.
13. An electronic device, It is characterized in that The electronic device includes a processor and a memory, wherein the memory stores at least one instruction or at least one program, and the at least one instruction or the at least one program is loaded and executed by the processor to implement a code detection method as described in any one of claims 1-6.
14. A computer-readable storage medium, It is characterized in that The storage medium includes a processor and a memory, wherein the memory stores at least one instruction or at least one program, and the at least one instruction or the at least one program is loaded and executed by the processor to implement a code detection method as described in any one of claims 1-6.
15. A computer program product comprising a computer program, It is characterized in that When the computer program is executed by a processor, the code detection method according to any one of claims 1 to 6 is implemented.
Citation Information
Patent Citations
Data acquisition method and device, electronic equipment and computer readable storage medium
CN110134400A
