[go: up one dir, main page]
More Web Proxy on the site http://driver.im/

CN112052073A - Script performance analysis method and device, readable storage medium and electronic equipment - Google Patents

Script performance analysis method and device, readable storage medium and electronic equipment Download PDF

Info

Publication number
CN112052073A
CN112052073A CN202010989944.1A CN202010989944A CN112052073A CN 112052073 A CN112052073 A CN 112052073A CN 202010989944 A CN202010989944 A CN 202010989944A CN 112052073 A CN112052073 A CN 112052073A
Authority
CN
China
Prior art keywords
target process
script
performance data
performance
call stack
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.)
Pending
Application number
CN202010989944.1A
Other languages
Chinese (zh)
Inventor
杨光栋
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Netease Hangzhou Network Co Ltd
Original Assignee
Netease Hangzhou Network Co Ltd
Priority date (The priority date 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 date listed.)
Filing date
Publication date
Application filed by Netease Hangzhou Network Co Ltd filed Critical Netease Hangzhou Network Co Ltd
Priority to CN202010989944.1A priority Critical patent/CN112052073A/en
Publication of CN112052073A publication Critical patent/CN112052073A/en
Pending legal-status Critical Current

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/44Arrangements for executing specific programs
    • G06F9/455Emulation; Interpretation; Software simulation, e.g. virtualisation or emulation of application or operating system execution engines
    • G06F9/45504Abstract machines for programme code execution, e.g. Java virtual machine [JVM], interpreters, emulators
    • G06F9/45508Runtime interpretation or emulation, e g. emulator loops, bytecode interpretation
    • G06F9/45512Command shells
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/46Multiprogramming arrangements
    • G06F9/50Allocation of resources, e.g. of the central processing unit [CPU]
    • G06F9/5005Allocation of resources, e.g. of the central processing unit [CPU] to service a request
    • G06F9/5011Allocation of resources, e.g. of the central processing unit [CPU] to service a request the resources being hardware resources other than CPUs, Servers and Terminals
    • G06F9/5016Allocation of resources, e.g. of the central processing unit [CPU] to service a request the resources being hardware resources other than CPUs, Servers and Terminals the resource being the memory

Landscapes

  • Engineering & Computer Science (AREA)
  • Software Systems (AREA)
  • Theoretical Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Debugging And Monitoring (AREA)

Abstract

The disclosure relates to the technical field of computers, and provides a script performance analysis method and device, a computer readable storage medium and an electronic device. Wherein, the method comprises the following steps: acquiring performance data of a target process according to a preset sampling period, wherein the target process is suspended at each sampling moment, the current performance data of the target process is acquired, and the operation of the target process is resumed after the acquisition of the current performance data is finished; determining the current performance data acquired at each sampling moment to generate a performance data set of the target process; and analyzing the script performance of the target process according to the performance data set. According to the scheme, the influence of the data acquisition process of script performance analysis on the running speed of the target process can be reduced based on the preset sampling period, and meanwhile, the performance data of the target process can be acquired under the condition that the code of the target process is not modified based on the data acquisition mode of the suspended target process.

Description

Script performance analysis method and device, readable storage medium and electronic equipment
Technical Field
The present disclosure relates to the field of computer technologies, and in particular, to a script performance analysis method, a script performance analysis apparatus, a computer-readable storage medium, and an electronic device.
Background
A scripting language is a computer programming language created to shorten the traditional write-compile-link-run (edge-compile-link-run) process. The method has more and more extensive application in the fields of game development, Web application, database expansion and the like, and bears more and more task logics, so that if the performance of a script program is not good, the running speed of an operating system can be directly influenced, and the analysis of the performance of the script language is very important.
Taking the Lua script language as an example, the performance analysis tool for the Lua script language at present is mainly Lua Profiler, which is a performance analysis tool of an embedded code formula. The operating principle is that a debug hook mechanism of Lua is utilized, after performance analysis is started, a hook is added to the beginning and the ending of each Lua function, the hook at the beginning of the function is responsible for recording the beginning execution time of the current function, and the hook at the end of the function is responsible for counting the current execution time of the current function and accumulating the information such as the total execution time and the total execution times of the current function. And after the performance analysis is finished, the Lua Profiler outputs the execution time and the execution times of each function according to the statistical data.
However, in the existing performance analysis method, a code needs to be embedded in an application program, and after performance analysis is started, the collection process of performance data occupies more computer memory resources, thereby affecting the current running speed of the application program.
It is to be noted that the information disclosed in the above background section is only for enhancement of understanding of the background of the present disclosure, and thus may include information that does not constitute prior art known to those of ordinary skill in the art.
Disclosure of Invention
The present disclosure is directed to providing a script language performance analysis method and apparatus, a computer readable storage medium, and an electronic device, so as to at least improve the problem that the data acquisition process of script performance analysis occupies large computer resources and affects the current running speed of an application program to a certain extent.
Additional features and advantages of the disclosure will be set forth in the detailed description which follows, or in part will be obvious from the description, or may be learned by practice of the disclosure.
According to a first aspect of the present disclosure, there is provided a script performance analysis method, including:
acquiring performance data of a target process according to a preset sampling period, wherein the target process is suspended at each sampling moment, the current performance data of the target process is acquired, and the running of the target process is resumed after the current performance data is acquired;
determining the current performance data acquired at each sampling moment to generate a performance data set of the target process;
and analyzing the script performance of the target process according to the performance data set.
In an exemplary embodiment of the present disclosure, based on the foregoing scheme, the acquiring performance data of the target process according to a preset sampling period includes:
responding to the trigger operation of starting the performance data of the acquisition target process, and acquiring a preset sampling period so as to acquire the performance data of the target process according to the preset sampling period.
In an exemplary embodiment of the present disclosure, based on the foregoing scheme, the generating a performance data set of the target process includes:
and in response to the triggering operation of closing the collection of the performance data of the target process, determining the current performance data collected at each sampling moment in the time period from the collection start to the collection closing so as to generate a performance data set of the target process.
In an exemplary embodiment of the disclosure, based on the foregoing solution, the generating the performance data set of the target process includes:
and determining the current performance data acquired at each sampling moment in a preset time period to generate a performance data set of the target process.
In an exemplary embodiment of the present disclosure, based on the foregoing scheme, the acquiring current performance data of the target process includes:
collecting a call stack of a current script layer of the target process;
the determining the current performance data acquired at each sampling time to generate the performance data set of the target process includes:
and determining the call stack of the current script layer of the target process acquired at each sampling moment so as to generate a call stack set of the script layer of the target process.
In an exemplary embodiment of the present disclosure, based on the foregoing solution, before the collecting the call stack of the current script layer of the target process, the method further includes:
obtaining a symbol table of the target process, and determining script version information corresponding to the target process according to a target function name in the symbol table;
and determining a target script unstacker of the target process according to the script version information, wherein the target script unstacker is used for reading a call stack of a current script layer of the target process.
In an exemplary embodiment of the disclosure, based on the foregoing solution, the acquiring current performance data of the target process further includes:
collecting a call stack of a current engine layer of the target process;
the determining the current performance data acquired at each sampling time to generate the performance data set of the target process further includes:
and determining the call stack of the current engine layer of the target process acquired at each sampling moment so as to generate a call stack set of the engine layer of the target process.
In an exemplary embodiment of the present disclosure, based on the foregoing scheme, the analyzing the script performance of the target process according to the performance data set includes:
determining the proportion of the occurrence times of each function in a call stack set of a script layer of the target process to the total sampling times;
and generating a first flame diagram according to the proportion of the occurrence times of the functions in the total sampling times and the call stack set of the script layer, and analyzing the script performance of the target process according to the first flame diagram.
In an exemplary embodiment of the present disclosure, based on the foregoing scheme, the analyzing the script performance of the target process according to the performance data set includes:
combining the call stack of the current engine layer and the call stack of the current script layer collected at each sampling moment to generate an integrated call stack at each sampling moment;
generating an integrated call stack set of the target process according to the integrated call stack at each sampling moment;
determining the proportion of the occurrence times of each function in the integrated call stack set to the total sampling times;
and generating a second flame diagram according to the proportion of the occurrence times of the functions to the total sampling times and the integrated call stack set, and analyzing the script performance of the target process according to the second flame diagram.
In an exemplary embodiment of the present disclosure, based on the foregoing scheme, the merging the call stack of the current engine layer and the call stack of the current script layer collected at each sampling time includes:
and replacing the function name in charge of executing the script program in the call stack of the engine layer with the function name corresponding to the executed script program in the call stack of the script layer.
In an exemplary embodiment of the present disclosure, based on the foregoing scheme, the analyzing the script performance of the target process according to the performance data set includes:
determining the proportion of the occurrence times of each function in a call stack set of a script layer of the target process to the total sampling times;
and sequencing the proportion to generate a first sequencing table of each function so as to analyze the script performance of the target process according to the first sequencing table.
In an exemplary embodiment of the present disclosure, based on the foregoing scheme, the analyzing the script performance of the target process according to the performance data set includes:
determining the proportion of the occurrence times of each function in the call stack set of the script layer and the call stack set of the engine layer of the target process to the total sampling times;
and sequencing the proportion to generate a second sequencing table of each function so as to analyze the script performance of the target process according to the second sequencing table. .
According to a second aspect of the present disclosure, there is provided a script performance analysis apparatus including:
the performance data acquisition module is configured to acquire performance data of a target process according to a preset sampling period, wherein at each sampling moment, the target process is suspended, the current performance data of the target process is acquired, and after the current performance data is acquired, the operation of the target process is resumed;
a performance data set determination module configured to determine the current performance data collected at each sampling time to generate a performance data set of the target process;
a performance analysis module configured to analyze script performance of the target process according to the performance data set.
According to a third aspect of the present disclosure, there is provided a computer-readable storage medium having stored thereon a computer program which, when executed by a processor, implements the script performance analyzing method as described in the first aspect of the embodiments above.
According to a fourth aspect of the embodiments of the present disclosure, there is provided an electronic apparatus including: a processor; and storage means for storing one or more programs which, when executed by the one or more processors, cause the one or more processors to implement the script performance analysis method as described in the first aspect of the embodiments above.
As can be seen from the foregoing technical solutions, the script performance analysis method, the script performance analysis apparatus, and the computer-readable storage medium and the electronic device for implementing the script performance analysis method in the exemplary embodiments of the present disclosure have at least the following advantages and positive effects:
in the technical solutions provided in some embodiments of the present disclosure, first, performance data of a target process is collected according to a preset sampling period, wherein at each sampling time, the target process is suspended, current performance data of the target process is collected, and after the current performance data is collected, the operation of the target process is resumed; secondly, determining the current performance data acquired at each sampling moment to generate a performance data set of the target process; then, the script performance of the target process is analyzed according to the performance data set. Compared with the prior art, on one hand, the method and the device can reduce the consumption of the data acquisition process of script performance analysis on the memory resource of the computer based on the preset sampling period, thereby reducing the influence on the running speed of the target process; on the other hand, the performance data of script analysis can be directly acquired based on the data acquisition mode of suspending the target process, acquiring data and recovering the operation of the target process without modifying the codes of the application program, so that the code maintenance cost of the script performance analysis is saved, and the flexibility of the script performance analysis is improved.
It is to be understood that both the foregoing general description and the following detailed description are exemplary and explanatory only and are not restrictive of the disclosure.
Drawings
The accompanying drawings, which are incorporated in and constitute a part of this specification, illustrate embodiments consistent with the present disclosure and together with the description, serve to explain the principles of the disclosure. It is to be understood that the drawings in the following description are merely exemplary of the disclosure, and that other drawings may be derived from those drawings by one of ordinary skill in the art without the exercise of inventive faculty.
FIG. 1 illustrates a flow diagram of a method of script performance analysis in an exemplary embodiment of the present disclosure;
FIG. 2 illustrates a flow diagram of a method of generating a set of performance data in an exemplary embodiment of the disclosure;
FIG. 3 illustrates call stacks of an engine layer and call stacks of a script layer collected in an exemplary embodiment of the present disclosure;
FIG. 4 is a diagram illustrating call stack merging before and after in an exemplary embodiment of the present disclosure;
FIG. 5 illustrates a second flame diagram generated in an exemplary embodiment of the present disclosure;
FIG. 6 illustrates a schematic diagram of a second sorted listing in an exemplary embodiment of the present disclosure;
FIG. 7 is a schematic structural diagram of a script performance analysis apparatus in an exemplary embodiment of the present disclosure;
FIG. 8 shows a schematic diagram of a structure of a computer storage medium in an exemplary embodiment of the disclosure; and the number of the first and second groups,
fig. 9 shows a schematic structural diagram of an electronic device in an exemplary embodiment of the present disclosure.
Detailed Description
Example embodiments will now be described more fully with reference to the accompanying drawings. Example embodiments may, however, be embodied in many different forms and should not be construed as limited to the examples set forth herein; rather, these embodiments are provided so that this disclosure will be thorough and complete, and will fully convey the concept of example embodiments to those skilled in the art. The described features, structures, or characteristics may be combined in any suitable manner in one or more embodiments. In the following description, numerous specific details are provided to give a thorough understanding of embodiments of the disclosure. One skilled in the relevant art will recognize, however, that the subject matter of the present disclosure can be practiced without one or more of the specific details, or with other methods, components, devices, steps, and the like. In other instances, well-known technical solutions have not been shown or described in detail to avoid obscuring aspects of the present disclosure.
The terms "a," "an," "the," and "said" are used in this specification to denote the presence of one or more elements/components/parts/etc.; the terms "comprising" and "having" are intended to be inclusive and mean that there may be additional elements/components/etc. other than the listed elements/components/etc.; the terms "first" and "second", etc. are used merely as labels, and are not limiting on the number of their objects.
Furthermore, the drawings are merely schematic illustrations of the present disclosure and are not necessarily drawn to scale. The same reference numerals in the drawings denote the same or similar parts, and thus their repetitive description will be omitted. Some of the block diagrams shown in the figures are functional entities and do not necessarily correspond to physically or logically separate entities.
A scripting language is a computer programming language created to shorten the traditional write-compile-link-run (edge-compile-link-run) process. The method has more and more extensive application in the fields of game development, Web application, database expansion and the like, and bears more and more task logics, so that if the performance of a script program is not good, the running speed of an operating system can be directly influenced, and the analysis of the performance of the script language is very important.
Taking the Lua script language as an example, the Lua script language is a lightweight, small and easy-to-use script language, and is designed to be embedded into an application program to provide flexible extensibility and customization functions for the application program.
With the development of game technology, the application of the Lua script language in the field of game development is deeper and deeper. Especially in mobile game development, in order to achieve fast development and fast iteration of products, the Lua script language starts to bear more and more game logic.
When the logic assumed by the Lua script is more and more complicated, if the code is not written well, the CPU (central processing unit) occupied by the program is too high, which affects the operating speed of the operating system.
In the related art, the performance analysis of the Lua scripting language can be performed by using Lua Profile. The Lua Profile is a performance analysis tool of an embedded code formula, and the working principle of the tool is that a debug hook mechanism of Lua is utilized, after performance analysis is started, a hook is added at the beginning and the ending of each Lua function, the hook at the beginning of the function is responsible for recording the starting execution time of the current function, and the hook at the end of the function is responsible for counting the current execution time of the current function and accumulating the information such as the total execution time and the total execution times of the current function. And after the performance analysis is finished, the Lua Profiler outputs the execution time and the execution times of each function according to the statistical data so as to enable a user to perform the performance analysis through the data, thereby optimizing the Lua script language.
However, when Lua scripting language performance analysis is performed using the Lua Profiler, the following problems may occur:
(1) the need to embed the code: that is, when using the Lua Profiler, its code must be introduced into the target program, and its interface needs to be called at the place where the performance analysis is started and ended, which increases the cost of the performance analysis.
(2) After the start-up performance analysis, a relatively large extra consumption is brought: because the Lua Profile adds a statistical hook at the beginning and the end of each Lua function, and the Lua functions are executed very frequently in an actual production environment, after the Profile is started, more computer memory resources are occupied, and the running speed of the application program is reduced.
(3) The statistical result lacks call chain information of the function: the Lua Profile can only count the execution time and the execution times of each function, the statistical result does not have the call relation among the functions, and the accuracy of performance analysis is reduced due to the lack of the call relation.
(4) Only the performance of the Lua script can be analyzed: the Lua Profile can only analyze the performance of the Lua script, but in an actual production environment, taking a game application as an example, the Lua script and a game engine are often closely combined, some performance problems may occur at an engine layer, and if information of the game engine layer is lacked, the accuracy of performance analysis may be reduced.
In an embodiment of the present disclosure, a script performance analysis method is first provided, which overcomes, at least to some extent, the above-mentioned shortcomings in the related art.
FIG. 1 shows a flowchart of a script performance analysis method in an exemplary embodiment of the present disclosure. Referring to fig. 1, the method includes:
step S110, collecting performance data of a target process according to a preset sampling period, wherein at each sampling moment, the target process is suspended, the current performance data of the target process is collected, and after the collection of the current performance data is finished, the operation of the target process is resumed;
step S120, determining the current performance data collected at each sampling moment to generate a performance data set of the target process;
and S130, analyzing the script performance of the target process according to the performance data set.
In the technical solution provided in the embodiment shown in fig. 1, first, performance data of a target process is collected according to a preset sampling period, wherein at each sampling time, the target process is suspended, current performance data of the target process is collected, and after the current performance data is collected, the operation of the target process is resumed; secondly, determining the current performance data acquired at each sampling moment to generate a performance data set of the target process; then, the script performance of the target process is analyzed according to the performance data set. Compared with the prior art, on one hand, the method and the device can reduce the consumption of the data acquisition process of script performance analysis on the memory resource of the computer based on the preset sampling period, thereby reducing the influence on the running speed of the target process; on the other hand, the performance data of script analysis can be directly acquired based on the data acquisition mode of suspending the target process, acquiring data and recovering the operation of the target process without modifying the codes of the application program, so that the code maintenance cost of the script performance analysis is saved, and the flexibility of the script performance analysis is improved.
The following detailed description of the various steps in the example shown in fig. 1:
in step S110, performance data of the target process is collected according to a preset sampling period, wherein at each sampling time, the target process is suspended, current performance data of the target process is collected, and after the collection of the current performance data is completed, the operation of the target process is resumed.
The preset sampling period may be set by a user according to a user requirement or a characteristic of the target program, for example, 10ms may be one sampling period, that is, the performance data of the target process is acquired at a preset frequency of 100 times per second.
It should be noted that, in general, the larger the preset sampling period is, the larger the time interval between two adjacent samples is, the lower the additional consumption brought to the target process is, but under the condition that the total sampling time is the same, the less the obtained performance data is, the lower the accuracy of the analysis result is; the smaller the preset sampling period is, the greater the additional consumption brought to the target process is, but under the condition that the total sampling time is the same, the more performance data are obtained, and the higher the accuracy of the analysis result is.
In an exemplary embodiment, the target process may include any program that can run in the background of the computer, and the target process may be one or more, and this exemplary embodiment is not particularly limited in this respect.
Illustratively, the collecting the performance data of the target process according to the preset sampling period includes: and responding to the trigger operation of starting the performance data of the acquisition target process, and acquiring a preset sampling period so as to acquire the performance data of the target process according to the preset sampling period.
Specifically, a user can set a value of a preset sampling period and a target process identifier in a human-computer interaction interface or a configuration file, after the setting is completed, the user can click to confirm or start to operate and other controls, the user responds to the triggering operation of the user on the controls for confirming or starting to operate and the like, the target process is paused at each sampling moment according to the preset sampling period so as to collect the current performance data of the target process, after the collection is completed, the operation of the target process is resumed, when the next sampling moment arrives, the target process is paused again so as to collect the current performance data of the target process, after the collection is completed, the operation of the target process is resumed, and the operation is repeated so as to collect the performance data of the target process according to the preset sampling period.
In an exemplary embodiment, the current performance data of the target process may include a call stack of a current script layer and/or a call stack of an engine layer of the target process. Specifically, the call stack of the script layer may be a function call relationship of the script layer in the running process of the target process, and the call stack of the engine layer may be a function call relationship of the engine layer in the running process of the target process.
Before collecting the call stack of the current script layer of the target process, the method further includes: acquiring a symbol table of a target process, and determining script version information corresponding to the target process according to a target function name in the symbol table; and determining a target script unstacker of the target process according to the script version information, wherein the target script unstacker is used for reading a call stack of the current script layer of the target process.
Specifically, the script unstacker may be a custom-written code that reads a call stack of a script layer corresponding to different versions of the lua. Taking the Lua script language as an example, when the Lua script language runs, a specific data structure is used to store the call stack of the current Lua script layer. Different versions of Lua use data structures that differ somewhat, especially Luajit, which is very different. Therefore, for each Lua version, a corresponding script unstacker can be written, so that the script unstacker can read the call stack of the script layer of the corresponding Lua version.
After performance data acquisition is started, a symbol table of a target process can be obtained, a Lua version used by the target process is determined according to a specific function name in the symbol table of the target process, and then when a sampling moment arrives, a script unstacker corresponding to the Lua version is called through the determined Lua version, and the script unstacker can read data in a corresponding data structure, so that a call stack of a current script layer is obtained.
For example, when lj _ debug _ dumpstack exists in the symbol table of the target process, it may be determined that the Lua version corresponding to the target process is luajitt 2.1, and at the sampling time, a unstacker corresponding to the luajitt 2.1 may be called to obtain a call stack of the current script layer of the target process.
TABLE 1
Name of objective function Lua version
lj_debug_dumpstack LuaJIT2.1
lj_vm_pcall LuaJIT2.0
Lua_isyieldable Lua5.3
LuaL_checkversion Lua5.2
luaV_execute Lua5.1
For example, the specific implementation manner of step S110 may be that, in response to the trigger operation of starting the collection of the performance data, a symbol table of the target process is obtained first, a Lua version used by the target process is determined according to a specific function name in the symbol table of the target process through table 1, and a target script unstacker is determined according to the Lua version; then, according to a preset sampling period, at each sampling time, calling a dynamic Attach to a target process by using a PTRACE () system call function to suspend the target process, then obtaining a call stack of a current engine layer of the target process by using a libenwind open source tool, reading a memory related to a Lua virtual machine of the target process by using a PTRACE () system call function call target script unstacker, analyzing the call stack of the current Lua script layer of the target process, and after the collection of the call stack of the current engine layer and the call stack of the script layer is completed, calling RACE _ ACH by using the PTRACE () system call function to recover the running DET of the target process. Therefore, according to the preset sampling period, when each sampling moment comes, the target process is suspended, the current call stack of the script layer and/or the call stack of the engine layer are/is acquired, and after the acquisition is completed, the performance data acquisition mode of program operation is recovered, so that codes can be prevented from being embedded in the application program, the performance data can be acquired without modifying the application program, and the code modification cost of performance data acquisition is saved. And the collection of performance data can be started and closed at any time so as to analyze the script performance of the application program at any time.
The Ptrace () is a debugging technology provided by the linux/unix system. With this technique, a program can be controlled, for example, to suspend/resume its operation, to read/set its memory data, and the like.
Furthermore, based on a preset sampling period, the running of the target process can be suspended only at the sampling moment, performance data are collected, and codes for additionally executing data collection are not needed when each script function is executed, so that the extra resource consumption of the data collection process of script performance analysis on the computer system can be reduced, and the influence of the script performance analysis on the running speed of the target process is further reduced.
Next, in step S120, the current performance data collected at each sampling instant is determined to generate a performance data set of the target process.
For example, a specific implementation manner of step S120 may be to determine, in response to a triggering operation of closing the acquisition of the performance data of the target process, current performance data acquired at each sampling time in a time period from the acquisition start to the acquisition close, so as to generate a performance data set of the target process.
For example, in a specific implementation manner of step S120, the current performance data collected at each sampling time within a preset time period may be determined to generate the performance data set of the target process.
The performance data set of the target process may include a call stack set of a script layer of the target process and/or a call stack set of an engine layer of the target process.
Illustratively, taking the example that the script language is Lua language and the target process is a program running in the game server, the method for generating the performance data set of the target process can be referred to fig. 2, and the method can include steps S210-S270.
In step S210, in response to the triggering operation of starting to collect performance data, a preset sampling period is obtained, and the Lua version in the game engine is identified.
Illustratively, in response to starting the trigger operation of collecting the performance data, the symbol table of the target process may be obtained, and then the Lua version used by the game engine is determined by the target function name in table 1.
In step S220, when the sampling time comes, the target process is suspended.
For example, whether the current sampling time is the sampling time or not may be determined according to a preset sampling period, and when the sampling time arrives, a ptrace () system may be used to call a function to call the dynamic Attach to the target process, so that the target process is suspended from running.
After the target process suspends, in step S230, the call stack of the current engine layer is acquired.
For example, a libonwind open source tool may be used to obtain a call stack of a current engine layer of a target process, a trace-back stack pointer may also be used to obtain the call stack of the current engine layer, and of course, other methods may also be used to obtain the call stack of the current engine layer, which is not limited in this exemplary embodiment.
Next, in step S240, according to the Lua version determined in step S210, a Lua script unstacker corresponding to the Lua version is called, and a call stack of the current script layer is acquired.
In an exemplary embodiment, the call stack of the current engine layer and the call stack of the script layer may be obtained as shown in fig. 3. Referring to fig. 3, the upper part of fig. 3 is a call stack 31 of an engine layer and the lower part is a call stack 32 of a script layer, with "═ lua" as a boundary.
After the collection of the current call stack of the target process is completed, in step S250, the operation of the target process is resumed.
In step S260, it is determined whether the sampling is currently finished, if so, the process goes to step S270, otherwise, the process waits for the next sampling time, and when the next sampling time comes, the process goes to step S220.
For example, when each sampling time comes, the above steps S220 to S250 may be repeated until the preset time is reached or the performance data collection is turned off, and the whole performance data collection process is ended, and the process goes to step S270.
In step S270, a call stack set is determined according to the call stack of the script layer and the call stack of the engine layer collected at each sampling time.
For example, the specific implementation manner of step S270 may be that the call stack of the script layer acquired at each sampling time determines the call stack set of the script layer according to the preset time or the time period from the start of acquisition to the end of acquisition, and the call stack of the engine layer acquired at each sampling time determines the call stack set of the engine layer according to the preset time or the time period from the start of acquisition to the end of acquisition.
For example, the specific implementation manner of step S270 may also be that the call stack of the engine layer and the call stack of the script layer collected at each sampling time are combined to generate an integrated call stack at each time, and the integrated call stack set is determined by the integrated call stack at each sampling time according to a preset time or a time period from the start of collection to the stop of collection.
With continued reference to FIG. 1, in step S130, the script performance of the target process is analyzed according to the performance data set.
In an exemplary embodiment, the set of performance data in step S130 may include a set of call stacks of an engine layer and/or a set of call stacks of a script layer of the target process.
For example, when the performance data set includes a call stack set of the script layer, the specific implementation of step S130 may be to determine the proportion of the occurrence number of each function in the call stack set of the script layer of the target process to the total sampling number; and generating a first flame diagram according to the proportion of the occurrence times of the functions in the total sampling times and the call stack set of the script layer, and analyzing the script performance of the target process according to the first flame diagram.
For example, when the performance data set includes a call stack set of the engine layer and a call stack set of the script layer, the specific implementation of step S130 may be that the call stack of the current engine layer and the call stack of the current script layer collected at each sampling time are merged to generate an integrated call stack at each sampling time; generating an integrated call stack set of the target process according to the integrated call stack at each sampling moment; determining the proportion of the occurrence frequency of each function in the integrated call stack set to the total sampling frequency; and generating a second flame diagram according to the proportion of the occurrence times of the functions in the total sampling times and the integrated call stack set, and analyzing the script performance of the target process according to the second flame diagram.
The specific implementation of combining the call stack of the current engine layer and the call stack of the current script layer acquired at each sampling moment may be to replace a function name in the call stack of the engine layer, which is responsible for executing the script program, with a function name corresponding to the script program executed in the call stack of the script layer.
Taking the lua5.1 version as an example, fig. 4 shows schematic diagrams before and after merging of a call stack of an engine layer and a call stack of a script layer, and in fig. 4, the left side is the call stack of the engine layer and the call stack of the script layer before merging, and it can be seen that, at this time, the left upper part of fig. 4 is the call stack of the engine layer, and the lower part is the call stack of the script layer, with ═ lua "as a dividing line. And the right side of fig. 4 is the integrated call stack after merging, and at this time, the engine call stack and the script call stack are merged.
The specific merging method may be to divide the call stack of the script layer before merging into different parts by using a function beginning with "[ C ]" as a dividing line. On the left side of FIG. 4, the call stack of the script layer is divided into two parts 41 and 42 by using "[ C ] luaB _ xpcalal" as a dividing line. Respectively and sequentially replacing 'luaV _ execute' in the call stack of the engine layer by using the call stack of the separated script layer, namely replacing the call stack 'luaV _ execute' 43 of the engine layer by using the call stack 41 of the script layer, and replacing the call stack 'luaV _ execute' 44 of the engine layer by using the call stack 42 of the script layer. In this way, a merged call stack of the engine layer and a call stack of the script layer, i.e., an integrated call stack, can be obtained, as shown in the right part of fig. 4.
Because the call stack of the engine layer and the call stack of the script layer can only be separately collected during collection, and the script and the engine are operated in a mutually staggered manner in the actual operation process, the separately collected call stacks are not visual, and the efficiency of script performance analysis can be reduced.
By the combination method, the call stacks of the engine layer and the script layer can be combined together according to the actual running condition so as to directly display the actual call relation between the call stacks in the flame diagram, thereby improving the efficiency of script performance analysis.
It should be noted that, the combining of the call stack of the script layer and the call stack of the engine layer acquired at each time may be performed after the acquisition at each time is completed, or may be performed after the entire data acquisition process is completed, and the call stack of the script layer and the call stack of the engine layer acquired at each time are combined in the call stack set of the script layer and the call stack set of the engine layer according to the sampling time.
Further, the second flame diagram generated may be as shown in FIG. 5. In the flame diagram, the lower function calls the upper function. Taking the "event _ base _ loop" function in the middle right of fig. 5 as an example, there are two functions "multi _ cb" and "_ encecb" above it, which means that "event _ base _ loop" will call two sub-functions "multi _ cb" and "_ encecb".
51, 52, 53, 54 in fig. 5 represent call stacks of the script layer, and the rest represent call stacks of the engine layer. The character representation in each bar in FIG. 5 is the name of the function in the call stack. The bar without characters is not displayed because the function name is larger than the bar width.
In fig. 5, the width occupied by each function represents the size of the consumption of the function, i.e., the ratio of the number of occurrences of each function described above to the total number of samples. For example, the total number of sampling times is 100, and the consumption of a function occurring in 20 samples is 20%, and the width of the corresponding function in the flame diagram is 20%.
The method comprises the steps of obtaining a call stack of an engine layer and a call stack of a script layer of a target process, combining the call stacks according to the actual program running condition, and then visually displaying the call relation among functions and the proportion of the functions in the total sampling times through a flame diagram, so that the performance hot points of the target process, namely the functions with larger proportion, can be determined more quickly, and the efficiency of script performance analysis is improved.
For example, when the performance data includes a call stack set of the engine layer, the specific implementation of step S130 may be to determine a proportion of the number of occurrences of each function in the call stack set of the engine layer of the target process in the total number of sampling times; and generating a third flame diagram according to the proportion of the occurrence times of the functions in the total sampling times and the call stack set of the engine layer, and analyzing the script performance of the target process according to the third flame diagram.
The first flame diagram and the third flame diagram can be generated directly according to the proportion of the occurrence times of the functions in the total sampling times and the corresponding call stack set. For example, when the performance data set includes a call stack set of the script layer, the specific implementation of step S130 may also be to determine a proportion of the occurrence number of each function in the call stack set of the script layer of the target process to the total sampling number; and sequencing the proportion to generate a first sequencing table of each function so as to analyze the script performance of the target process according to the first sequencing table.
For example, when the performance data set includes a call stack set of a script layer and a call stack set of an engine layer, the specific implementation of step S130 may also be to determine a proportion of the occurrence number of each function in the call stack set of the script layer and the call stack set of the engine layer of the target process to the total sampling number; and sequencing the proportion to generate a second sequencing table of each function so as to analyze the script performance of the target process according to the second sequencing table.
For example, when the performance data set includes a call stack set of the engine layer, the specific implementation of step S130 may also be that the proportion of the occurrence number of each function in the call stack set of the engine layer of the target process to the total sampling number is determined; and sequencing the proportion to generate a third sequencing table of each function so as to analyze the script performance of the target process according to the third sequencing table.
The above sorting according to specific gravity may include sorting according to a sequence from a large specific gravity to a small specific gravity, or sorting according to a sequence from a small specific gravity to a large specific gravity, which is not limited in this exemplary embodiment.
Of course, the function names with N bits before sorting and the corresponding specific gravity can also be sorted according to the specific gravity from the order of magnitude and displayed in the sorting table. As shown in fig. 6, the top 5 ordered functions and their corresponding weightings are shown.
Through the sequencing table, the performance hot spot of the target process can be directly determined, namely, more functions are used in the running process of the target process, so that the target process can be optimized, and the efficiency of script performance analysis is improved.
Furthermore, since the same function may be scattered over different "peaks" in the flame diagram, it is not easy to quickly determine the total specific gravity of the function, and the total specific gravity of the function is displayed only once in the ranking table. Therefore, when performing the script performance analysis, the flame diagram and the ranking table can be combined to improve the accuracy and efficiency of the performance analysis.
For example, when there is no particularly wide "peak" in the flame diagram, a function with a higher specific gravity can be quickly found from the sorting table, and then the position of the function is found in the flame diagram, and according to the call relationship displayed in the flame diagram, it can be seen which child functions are called by the function, and which parent functions are called by the function, so as to attempt performance optimization.
Through the steps S110 to S130, based on the data collection manner of the suspended target process, the performance data of the target process can be directly collected without any modification to the target process, so that the code modification cost of the script performance analysis can be reduced. Meanwhile, script performance data acquisition can be started and closed at any time, and flexibility of script performance analysis is improved.
Furthermore, based on the preset sampling period, the sampling frequency can be controlled, and then the additional consumption of the data acquisition process of script performance analysis to the target process is controlled, so that the influence of the data acquisition process on the running speed of the target process is reduced, and the method is suitable for being used in a production environment.
By automatically identifying script versions and different script unstackers corresponding to different script versions, the method can be simultaneously adapted to script languages of various versions, and can simultaneously support Lua5.1, Lua5.2, Lua5.3, LuaJIT2.0, LuaJIT2.1 and the like by taking Lua language as an example.
In addition, the call stack of the script layer and the call stack of the engine layer are collected and combined according to the actual running condition, so that the call relation among the functions in the running process of the target process and the call proportion of the functions can be visually displayed in a flame diagram, the performance hot spot of the target process can be visually and quickly determined, and the efficiency and the accuracy of performance analysis of the script are improved.
Those skilled in the art will appreciate that all or part of the steps implementing the above embodiments are implemented as computer programs executed by a CPU. The computer program, when executed by the CPU, performs the functions defined by the method provided by the present invention. The program may be stored in a computer readable storage medium, which may be a read-only memory, a magnetic or optical disk, or the like.
Furthermore, it should be noted that the above-mentioned figures are only schematic illustrations of the processes involved in the method according to exemplary embodiments of the invention, and are not intended to be limiting. It will be readily understood that the processes shown in the above figures are not intended to indicate or limit the chronological order of the processes. In addition, it is also readily understood that these processes may be performed synchronously or asynchronously, e.g., in multiple modules.
Fig. 7 shows a schematic structural diagram of a script performance analysis apparatus in an exemplary embodiment of the present disclosure. Illustratively, referring to fig. 7, the script performance analyzing apparatus 700 may include: a performance data collection module 710, a performance data set determination module 720, and a performance analysis module 730. Wherein:
the performance data acquisition module 710 is configured to acquire performance data of the target process according to a preset sampling period, wherein at each sampling time, the target process is suspended, current performance data of the target process is acquired, and after the acquisition of the current performance data is completed, the operation of the target process is resumed;
the performance data set determining module 720 is configured to determine the current performance data collected at each sampling time to generate a performance data set of the target process;
the performance analysis module 730 is configured to analyze the script performance of the target process according to the performance data set.
In an exemplary embodiment of the present disclosure, based on the foregoing embodiment, the performance data collecting module 710 includes an opening unit configured to:
and responding to the trigger operation of starting the performance data of the acquisition target process, and acquiring a preset sampling period so as to acquire the performance data of the target process according to the preset sampling period.
In an exemplary embodiment of the present disclosure, based on the foregoing embodiment, the performance data set determining module 720 includes a closing unit configured to:
and in response to the triggering operation of closing the collection of the performance data of the target process, determining the current performance data collected at each sampling moment in the time period from the collection start to the collection closing so as to generate a performance data set of the target process.
In an exemplary embodiment of the present disclosure, based on the foregoing embodiment, the performance data set determining module 720 is further specifically configured to:
and determining the current performance data acquired at each sampling moment in a preset time period to generate a performance data set of the target process.
In an exemplary embodiment of the present disclosure, based on the foregoing embodiment, the performance data set determining module 720 includes a script call stack set determining unit, and the script call stack set determining unit is configured to:
and determining the call stack of the current script layer of the target process acquired at each sampling moment to generate a call stack set of the script layer of the target process.
In an exemplary embodiment of the present disclosure, based on the foregoing embodiment, the foregoing opening unit is further specifically configured to:
acquiring a symbol table of a target process, and determining script version information corresponding to the target process according to a target function name in the symbol table;
and determining a target script unstacker of the target process according to the script version information, wherein the target script unstacker is used for reading a call stack of the current script layer of the target process.
In an exemplary embodiment of the present disclosure, based on the foregoing embodiment, the performance data set determining module 720 further includes an engine call stack set determining unit, where the engine call stack set determining unit is configured to:
and determining the call stack of the current engine layer of the target process acquired at each sampling moment so as to generate a call stack set of the engine layer of the target process.
In an exemplary embodiment of the present disclosure, based on the foregoing embodiment, the performance analysis module 730 includes a first flame map generation unit configured to:
determining the proportion of the occurrence times of each function in a call stack set of a script layer of a target process to the total sampling times;
and generating a first flame diagram according to the proportion of the occurrence times of the functions in the total sampling times and the call stack set of the script layer, and analyzing the script performance of the target process according to the first flame diagram.
In an exemplary embodiment of the present disclosure, based on the foregoing embodiment, the performance analysis module 730 includes a second flame map generation unit configured to:
combining the call stack of the current engine layer and the call stack of the current script layer collected at each sampling moment to generate an integrated call stack at each sampling moment;
generating an integrated call stack set of the target process according to the integrated call stack at each sampling moment;
determining the proportion of the occurrence frequency of each function in the integrated call stack set to the total sampling frequency;
and generating a second flame diagram according to the proportion of the occurrence times of the functions in the total sampling times and the integrated call stack set, and analyzing the script performance of the target process according to the second flame diagram.
In an exemplary embodiment of the present disclosure, based on the foregoing embodiment, the performance analysis module 730 includes a first sorting table generation unit configured to:
determining the proportion of the occurrence times of each function in a call stack set of a script layer of a target process to the total sampling times;
and sorting the proportion to generate a first sorting table of each function so as to analyze the script performance of the target process according to the first sorting table.
In an exemplary embodiment of the disclosure, based on the foregoing embodiment, the performance analysis module 730 includes a second sorting table generation unit, configured to:
determining the proportion of the occurrence frequency of each function in a call stack set of a script layer and a call stack set of an engine layer of a target process to the total sampling frequency;
and sequencing the proportion to generate a second sequencing table of each function, and analyzing the script performance of the target process according to the second sequencing table.
The specific details of each unit in the script performance analysis apparatus have been described in detail in the corresponding script performance analysis method, and therefore are not described herein again.
It should be noted that although in the above detailed description several modules or units of the device for action execution are mentioned, such a division is not mandatory. Indeed, the features and functionality of two or more modules or units described above may be embodied in one module or unit, according to embodiments of the present disclosure. Conversely, the features and functions of one module or unit described above may be further divided into embodiments by a plurality of modules or units.
Moreover, although the steps of the methods of the present disclosure are depicted in the drawings in a particular order, this does not require or imply that the steps must be performed in this particular order, or that all of the depicted steps must be performed, to achieve desirable results. Additionally or alternatively, certain steps may be omitted, multiple steps combined into one step execution, and/or one step broken down into multiple step executions, etc.
Through the above description of the embodiments, those skilled in the art will readily understand that the exemplary embodiments described herein may be implemented by software, or by software in combination with necessary hardware. Therefore, the technical solution according to the embodiments of the present disclosure may be embodied in the form of a software product, which may be stored in a non-volatile storage medium (which may be a CD-ROM, a usb disk, a removable hard disk, etc.) or on a network, and includes several instructions to enable a computing device (which may be a personal computer, a server, a mobile terminal, or a network device, etc.) to execute the method according to the embodiments of the present disclosure.
In an exemplary embodiment of the present disclosure, there is also provided a computer storage medium capable of implementing the above method. On which a program product capable of implementing the above-described method of the present specification is stored. In some possible embodiments, various aspects of the disclosure may also be implemented in the form of a program product comprising program code for causing a terminal device to perform the steps according to various exemplary embodiments of the disclosure described in the "exemplary methods" section above of this specification, when the program product is run on the terminal device.
Referring to fig. 8, a program product 800 for implementing the above method according to an embodiment of the present disclosure is described, which may employ a portable compact disc read only memory (CD-ROM) and include program code, and may be run on a terminal device, such as a personal computer. However, the program product of the present disclosure is not limited thereto, and in this document, a readable storage medium may be any tangible medium that can contain, or store a program for use by or in connection with an instruction execution system, apparatus, or device.
The program product may employ any combination of one or more readable media. The readable medium may be a readable signal medium or a readable storage medium. A readable storage medium may be, for example, but not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or any combination of the foregoing. More specific examples (a non-exhaustive list) of the readable storage medium include: an electrical connection having one or more wires, a portable disk, a hard disk, a Random Access Memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disc read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing.
A computer readable signal medium may include a propagated data signal with readable program code embodied therein, for example, in baseband or as part of a carrier wave. Such a propagated data signal may take many forms, including, but not limited to, electro-magnetic, optical, or any suitable combination thereof. A readable signal medium may also be any readable medium that is not a readable storage medium and that can communicate, propagate, or transport a program for use by or in connection with an instruction execution system, apparatus, or device.
Program code embodied on a readable medium may be transmitted using any appropriate medium, including but not limited to wireless, wireline, optical fiber cable, RF, etc., or any suitable combination of the foregoing.
Program code for carrying out operations for the present disclosure may be written in any combination of one or more programming languages, including an object oriented programming language such as Java, C + + or the like and conventional procedural programming languages, such as the "C" programming language or similar programming languages. The program code may execute entirely on the user's computing device, partly on the user's device, as a stand-alone software package, partly on the user's computing device and partly on a remote computing device, or entirely on the remote computing device or server. In the case of a remote computing device, the remote computing device may be connected to the user computing device through any kind of network, including a Local Area Network (LAN) or a Wide Area Network (WAN), or may be connected to an external computing device (e.g., through the internet using an internet service provider).
In addition, in an exemplary embodiment of the present disclosure, an electronic device capable of implementing the above method is also provided.
As will be appreciated by one skilled in the art, aspects of the present disclosure may be embodied as a system, method or program product. Accordingly, various aspects of the present disclosure may be embodied in the form of: an entirely hardware embodiment, an entirely software embodiment (including firmware, microcode, etc.) or an embodiment combining hardware and software aspects that may all generally be referred to herein as a "circuit," module "or" system.
An electronic device 900 according to this embodiment of the disclosure is described below with reference to fig. 9. The electronic device 900 shown in fig. 9 is only an example and should not bring any limitations to the functionality or scope of use of the embodiments of the present disclosure.
As shown in fig. 9, the electronic device 900 is embodied in the form of a general purpose computing device. Components of electronic device 900 may include, but are not limited to: the at least one processing unit 910, the at least one storage unit 920, a bus 930 connecting different system components (including the storage unit 920 and the processing unit 910), and a display unit 940.
Wherein the storage unit stores program code that is executable by the processing unit 910 to cause the processing unit 910 to perform the steps according to various exemplary embodiments of the present disclosure described in the above section "exemplary method" of the present specification: step S110, collecting performance data of a target process according to a preset sampling period, wherein at each sampling moment, the target process is suspended, the current performance data of the target process is collected, and after the collection of the current performance data is finished, the operation of the target process is resumed; step S120, determining the current performance data collected at each sampling moment to generate a performance data set of the target process; and S130, analyzing the script performance of the target process according to the performance data set.
The storage unit 920 may include a readable medium in the form of a volatile storage unit, such as a random access memory unit (RAM)9201 and/or a cache memory unit 9202, and may further include a read only memory unit (ROM) 9203.
Storage unit 920 may also include a program/utility 9204 having a set (at least one) of program modules 8205, such program modules 9205 including, but not limited to: an operating system, one or more application programs, other program modules, and program data, each of which, or some combination thereof, may comprise an implementation of a network environment.
Bus 930 can be any of several types of bus structures including a memory unit bus or memory unit controller, a peripheral bus, an accelerated graphics port, a processing unit, or a local bus using any of a variety of bus architectures.
The electronic device 900 may also communicate with one or more external devices 1000 (e.g., keyboard, pointing device, bluetooth device, etc.), with one or more devices that enable a user to interact with the electronic device 900, and/or with any devices (e.g., router, modem, etc.) that enable the electronic device 900 to communicate with one or more other computing devices. Such communication may occur via input/output (I/O) interface 950. Also, the electronic device 900 may communicate with one or more networks (e.g., a Local Area Network (LAN), a Wide Area Network (WAN) and/or a public network, such as the Internet) via the network adapter 960. As shown, the network adapter 960 communicates with the other modules of the electronic device 900 via the bus 930. It should be appreciated that although not shown, other hardware and/or software modules may be used in conjunction with the electronic device 900, including but not limited to: microcode, device drivers, redundant processing units, external disk drive arrays, RAID systems, tape drives, and data backup storage systems, among others.
Through the above description of the embodiments, those skilled in the art will readily understand that the exemplary embodiments described herein may be implemented by software, or by software in combination with necessary hardware. Therefore, the technical solution according to the embodiments of the present disclosure may be embodied in the form of a software product, which may be stored in a non-volatile storage medium (which may be a CD-ROM, a usb disk, a removable hard disk, etc.) or on a network, and includes several instructions to enable a computing device (which may be a personal computer, a server, a terminal device, or a network device, etc.) to execute the method according to the embodiments of the present disclosure.
Furthermore, the above-described figures are merely schematic illustrations of processes included in methods according to exemplary embodiments of the present disclosure, and are not intended to be limiting. It will be readily understood that the processes shown in the above figures are not intended to indicate or limit the chronological order of the processes. In addition, it is also readily understood that these processes may be performed synchronously or asynchronously, e.g., in multiple modules.
Other embodiments of the disclosure will be apparent to those skilled in the art from consideration of the specification and practice of the disclosure disclosed herein. This application is intended to cover any variations, uses, or adaptations of the disclosure following, in general, the principles of the disclosure and including such departures from the present disclosure as come within known or customary practice within the art to which the disclosure pertains. It is intended that the specification and examples be considered as exemplary only, with a true scope and spirit of the disclosure being indicated by the following claims.

Claims (15)

1. A script performance analysis method, comprising:
acquiring performance data of a target process according to a preset sampling period, wherein the target process is suspended at each sampling moment, the current performance data of the target process is acquired, and the running of the target process is resumed after the current performance data is acquired;
determining the current performance data acquired at each sampling moment to generate a performance data set of the target process;
and analyzing the script performance of the target process according to the performance data set.
2. The script performance analyzing method of claim 1, wherein the collecting performance data of the target process according to the preset sampling period comprises:
responding to the trigger operation of starting the performance data of the acquisition target process, and acquiring a preset sampling period so as to acquire the performance data of the target process according to the preset sampling period.
3. The script performance analysis method of claim 2, wherein said generating a set of performance data for the target process comprises:
and in response to the triggering operation of closing the collection of the performance data of the target process, determining the current performance data collected at each sampling moment in the time period from the collection start to the collection closing so as to generate a performance data set of the target process.
4. The script performance analysis method of claim 1, wherein said generating a set of performance data for the target process comprises:
and determining the current performance data acquired at each sampling moment in a preset time period to generate a performance data set of the target process.
5. The script performance analyzing method according to any one of claims 1 to 4, wherein the collecting current performance data of a target process comprises:
collecting a call stack of a current script layer of the target process;
the determining the current performance data acquired at each sampling time to generate the performance data set of the target process includes:
and determining the call stack of the current script layer of the target process acquired at each sampling moment so as to generate a call stack set of the script layer of the target process.
6. The script performance analyzing method of claim 5, wherein prior to collecting a call stack of a current script layer of the target process, the method further comprises:
obtaining a symbol table of the target process, and determining script version information corresponding to the target process according to a target function name in the symbol table;
and determining a target script unstacker of the target process according to the script version information, wherein the target script unstacker is used for reading a call stack of a current script layer of the target process.
7. The script performance analyzing method of claim 5, wherein the collecting current performance data of the target process further comprises:
collecting a call stack of a current engine layer of the target process;
the determining the current performance data acquired at each sampling time to generate the performance data set of the target process further includes:
and determining the call stack of the current engine layer of the target process acquired at each sampling moment so as to generate a call stack set of the engine layer of the target process.
8. The script performance analyzing method of claim 5, wherein analyzing the script performance of the target process according to the performance data set comprises:
determining the proportion of the occurrence times of each function in a call stack set of a script layer of the target process to the total sampling times;
and generating a first flame diagram according to the proportion of the occurrence times of the functions in the total sampling times and the call stack set of the script layer, and analyzing the script performance of the target process according to the first flame diagram.
9. The script performance analyzing method of claim 7, wherein analyzing the script performance of the target process according to the performance data set comprises:
combining the call stack of the current engine layer and the call stack of the current script layer collected at each sampling moment to generate an integrated call stack at each sampling moment;
generating an integrated call stack set of the target process according to the integrated call stack at each sampling moment;
determining the proportion of the occurrence times of each function in the integrated call stack set to the total sampling times;
and generating a second flame diagram according to the proportion of the occurrence times of the functions to the total sampling times and the integrated call stack set, and analyzing the script performance of the target process according to the second flame diagram.
10. The script performance analyzing method according to claim 9, wherein said merging the call stack of the current engine layer and the call stack of the current script layer collected at each sampling time comprises:
and replacing the function name in charge of executing the script program in the call stack of the engine layer with the function name corresponding to the executed script program in the call stack of the script layer.
11. The script performance analyzing method of claim 5, wherein analyzing the script performance of the target process according to the performance data set comprises:
determining the proportion of the occurrence times of each function in a call stack set of a script layer of the target process to the total sampling times;
and sequencing the proportion to generate a first sequencing table of each function so as to analyze the script performance of the target process according to the first sequencing table.
12. The script performance analyzing method of claim 7, wherein analyzing the script performance of the target process according to the performance data set comprises:
determining the proportion of the occurrence times of each function in the call stack set of the script layer and the call stack set of the engine layer of the target process to the total sampling times;
and sequencing the proportion to generate a second sequencing table of each function so as to analyze the script performance of the target process according to the second sequencing table.
13. A script performance analysis apparatus, comprising:
the performance data acquisition module is configured to acquire performance data of a target process according to a preset sampling period, wherein at each sampling moment, the target process is suspended, the current performance data of the target process is acquired, and after the current performance data is acquired, the operation of the target process is resumed;
a performance data set determination module configured to determine the current performance data collected at each sampling time to generate a performance data set of the target process;
a performance analysis module configured to analyze script performance of the target process according to the performance data set.
14. A computer-readable storage medium on which a computer program is stored, the program, when executed by a processor, implementing the script performance analysis method of any one of claims 1 to 12.
15. An electronic device, comprising:
one or more processors;
storage means for storing one or more programs which, when executed by the one or more processors, cause the one or more processors to implement the script performance analysis method of any one of claims 1 to 12.
CN202010989944.1A 2020-09-18 2020-09-18 Script performance analysis method and device, readable storage medium and electronic equipment Pending CN112052073A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202010989944.1A CN112052073A (en) 2020-09-18 2020-09-18 Script performance analysis method and device, readable storage medium and electronic equipment

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202010989944.1A CN112052073A (en) 2020-09-18 2020-09-18 Script performance analysis method and device, readable storage medium and electronic equipment

Publications (1)

Publication Number Publication Date
CN112052073A true CN112052073A (en) 2020-12-08

Family

ID=73604132

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202010989944.1A Pending CN112052073A (en) 2020-09-18 2020-09-18 Script performance analysis method and device, readable storage medium and electronic equipment

Country Status (1)

Country Link
CN (1) CN112052073A (en)

Cited By (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN113209613A (en) * 2021-05-19 2021-08-06 网易(杭州)网络有限公司 Flame diagram analysis method and device, electronic equipment and medium
CN113934475A (en) * 2021-08-10 2022-01-14 荣耀终端有限公司 Application call analysis method and electronic equipment
CN114064011A (en) * 2021-11-25 2022-02-18 北京字跳网络技术有限公司 Method, device, storage medium and electronic equipment for determining process performance
CN116974922A (en) * 2023-07-25 2023-10-31 摩尔线程智能科技(北京)有限责任公司 Performance analysis method, device, equipment and storage medium of deep learning model

Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN106227671A (en) * 2016-08-05 2016-12-14 网易(杭州)网络有限公司 Program analysis of running performance method and device
US20190340392A1 (en) * 2018-05-04 2019-11-07 New York University Anomaly detection in real-time multi-threaded processes on embedded systems and devices using hardware performance counters and/or stack traces
CN110457277A (en) * 2019-08-19 2019-11-15 北京博睿宏远数据科技股份有限公司 Service process performance analysis method, device, equipment and storage medium
CN110457211A (en) * 2019-07-23 2019-11-15 腾讯科技(深圳)有限公司 Script performance test methods, device and equipment and computer storage medium
CN111382044A (en) * 2020-02-29 2020-07-07 深圳市腾讯信息技术有限公司 Positioning method and positioning device for performance bottleneck, electronic equipment and storage medium

Patent Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN106227671A (en) * 2016-08-05 2016-12-14 网易(杭州)网络有限公司 Program analysis of running performance method and device
US20190340392A1 (en) * 2018-05-04 2019-11-07 New York University Anomaly detection in real-time multi-threaded processes on embedded systems and devices using hardware performance counters and/or stack traces
CN110457211A (en) * 2019-07-23 2019-11-15 腾讯科技(深圳)有限公司 Script performance test methods, device and equipment and computer storage medium
CN110457277A (en) * 2019-08-19 2019-11-15 北京博睿宏远数据科技股份有限公司 Service process performance analysis method, device, equipment and storage medium
CN111382044A (en) * 2020-02-29 2020-07-07 深圳市腾讯信息技术有限公司 Positioning method and positioning device for performance bottleneck, electronic equipment and storage medium

Non-Patent Citations (1)

* Cited by examiner, † Cited by third party
Title
网友: "《使用ptrace来获取跨进程的python-cpp 混合栈》", 《HTTPS://ZHUANLAN.ZHIHU.COM/P/186317563?UTM_ID=0》 *

Cited By (7)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN113209613A (en) * 2021-05-19 2021-08-06 网易(杭州)网络有限公司 Flame diagram analysis method and device, electronic equipment and medium
CN113209613B (en) * 2021-05-19 2024-05-28 网易(杭州)网络有限公司 Flame pattern analysis method and device, electronic equipment and medium
CN113934475A (en) * 2021-08-10 2022-01-14 荣耀终端有限公司 Application call analysis method and electronic equipment
CN113934475B (en) * 2021-08-10 2022-09-06 荣耀终端有限公司 Application call analysis method and electronic equipment
CN114064011A (en) * 2021-11-25 2022-02-18 北京字跳网络技术有限公司 Method, device, storage medium and electronic equipment for determining process performance
CN116974922A (en) * 2023-07-25 2023-10-31 摩尔线程智能科技(北京)有限责任公司 Performance analysis method, device, equipment and storage medium of deep learning model
CN116974922B (en) * 2023-07-25 2024-05-17 摩尔线程智能科技(北京)有限责任公司 Performance analysis method, device, equipment and storage medium of deep learning model

Similar Documents

Publication Publication Date Title
CN112052073A (en) Script performance analysis method and device, readable storage medium and electronic equipment
Ratanaworabhan et al. {JSMeter}: Comparing the Behavior of {JavaScript} Benchmarks with Real Web Applications
CN102341790B (en) Data processing system and use method thereof
US8924912B2 (en) Method of recording and replaying call frames for a test bench
CN110457211B (en) Script performance test method, device and equipment and computer storage medium
US7739662B2 (en) Methods and apparatus to analyze processor systems
US9524180B2 (en) Managing virtual machines using tracing information
JPH0689200A (en) Debug system and method
CN103838663A (en) Application testing method and device
CN108920382B (en) Test case generation method and device, storage medium and server
CN110941553A (en) Code detection method, device, equipment and readable storage medium
CN101183332A (en) Method and device for automatically generating testing datasets by program content
CN110908915A (en) Test coverage rate display method and device and computer system
CN117195568A (en) Simulation engine performance analysis method and device based on discrete event
CN115357515B (en) Debugging method and device of multi-core system, computer equipment and storage medium
CN105760638A (en) SOC-chip simulation accelerating method
Li et al. Effectively manifesting concurrency bugs in android apps
CN110990285A (en) UI automation test method and device
CN110990243A (en) Caton analysis method and device, storage medium and computing equipment
US8819626B2 (en) Sharable development environment bookmarks for functional/data flow
CN108021495B (en) Code debugging method based on playback
Pereira et al. Dynamic phase analysis for cycle-close trace generation
CN112861138A (en) Software security analysis method and analysis device, electronic device, and storage medium
Flanagan et al. Incomplete trace data and trace driven simulation
CN112181853A (en) Program debugging method, device and system

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