Summary of the invention
To solve the above problems, the purpose of the present invention is to provide a kind of method and system for optimizing game running, including
Model formulates step, and simultaneously each fineness correspondence is arranged in the model gradually reduce at least two fineness of modelling in game
Transmission frame number per second, i.e. frame number grade;Game monitoring step executes games, grabs the parameters in game running;
Running optimizatin step, executes comparison according to transmission frame number per second and each frame number grade, and transmission frame number per second is more than or equal to frame
The corresponding model of number grade is set as the model of going game program display;Repeat game monitoring step and running optimizatin
Step, until games are out of service.
On the one hand technical solution used by the present invention solves the problems, such as it is: a method of optimization game running, it is special
Sign is, method includes the following steps: model formulates step, gradually drops at least two fineness of modelling in game
Simultaneously the corresponding transmission frame number per second of each fineness, i.e. frame number grade is arranged in low model;Game monitoring step executes game journey
Sequence grabs the parameters in game running, and wherein parameter includes but is not limited to transmission frame number per second;Running optimizatin step, root
Comparison is executed according to transmission frame number per second and each frame number grade, transmission frame number per second is more than or equal to the corresponding model of frame number grade
It is set as the model of going game program display;Game monitoring step and running optimizatin step are repeated, until game journey
Sequence is out of service.
Further, it includes: crawl game resource that the model, which formulates step, obtains model file;Use reduction model
The method of fineness obtains the different model of multiple finenesses, wherein the method for reducing model fineness includes but is not limited to reduce
The face of model and reduction number of grid;Model is ranked up according to the height of fineness, and according to hierarchical policy to each
The value of corresponding transmission frame number per second is arranged in model, obtains the corresponding frame number grade of each model.
Further, the hierarchical policy is corresponding frame number grade to be arranged according to model fineness, model fineness is got over
The value of height, the transmission frame number per second of corresponding frame number grade is higher.
Further, the game monitoring step includes: to inject monitoring script to games or call engine interface, is obtained
Take parameter when game running, transmission frame number including but not limited to per second, Center Processing Unit Utilization, graphics processor occupancy
And memory usage.
Further, the running optimizatin step includes: the transmission frame number per second obtained in a period of time, and does average place
Reason, obtains frame number average value, wherein can customize for a period of time;Obtained frame number average value and the frame number grade of setting are carried out
It compares and makes the difference one by one and take absolute value, judge whether frame number average value is greater than frame number grade, if then by the frame of maximum absolute value
Number grade is as objective optimization frame number grade, otherwise using the smallest frame number grade of absolute value as objective optimization frame number grade;It will
The corresponding model of objective optimization frame number grade is set as the model of going game program display.
On the other hand technical solution used by the present invention solves the problems, such as it is: a kind of system optimizing game running,
It is characterized in that, comprising: model optimization module, the model for gradually being reduced at least two fineness of modelling in game
And the corresponding transmission frame number per second of each fineness, i.e. frame number grade are set;Game monitoring modular is grabbed for executing games
Take the parameters in game running;Game optimization module, for according to transmission frame number per second and the execution pair of each frame number grade
Than transmission frame number per second is more than or equal to the model that the corresponding model of frame number grade is set as going game program display;Game
Process detection module sends sense command to other modules for detecting whether games run, and according to result.
Further, the model optimization module includes model processing modules, for the face by reduction model and is subtracted
Lack number of grid to reduce the fineness of model.
Further, the game optimization module includes: frame number processing module, for obtaining the biography per second in a period of time
Defeated frame number, and average treatment is done, frame number average value is obtained, wherein can customize for a period of time;Judgment module, for what will be obtained
Frame number average value and the frame number grade of setting are compared one by one and are made the difference and taken absolute value, and judge whether frame number average value is greater than frame
Number grade, if then using the frame number grade of maximum absolute value as objective optimization frame number grade, otherwise by the smallest frame of absolute value
Number grade is as objective optimization frame number grade;Model setup module, for the corresponding model of objective optimization frame number grade to be arranged
For the model of going game program display.
The beneficial effects of the present invention are: a kind of method and system for optimization game running that the present invention uses, by being directed to
The fineness of model in game was arranged according to transmission frame number per second, runs and protects in neither image game the case where game running
In the case where demonstrate,proving user experience, guarantees the fineness of game picture, improve the game experiencing of user.
Specific embodiment
It is carried out below with reference to technical effect of the embodiment and attached drawing to design of the invention, specific structure and generation clear
Chu, complete description, to be completely understood by the purpose of the present invention, scheme and effect.
It should be noted that unless otherwise specified, the descriptions such as upper and lower, left and right used in the disclosure are only opposite
In attached drawing for the mutual alignment relation of each component part of the disclosure." the one of used singular in the disclosure
Kind ", " described " and "the" are also intended to including most forms, unless the context clearly indicates other meaning.In addition, unless otherwise
Definition, all technical and scientific terms used herein and the normally understood meaning phase of those skilled in the art
Together.Term used in the description is intended merely to description specific embodiment herein, is not intended to be limiting of the invention.
The use of provided in this article any and all example or exemplary language (" such as ", " such as ") is intended merely to more
Illustrate the embodiment of the present invention well, and unless the context requires otherwise, otherwise the scope of the present invention will not be applied and be limited.
FPS- is the definition in image domains, refers to picture transmission frame number per second, just refers to animation or video for popular
Frame numbers.FPS is the information content measured for saving, showing dynamic video.Each second frame number the more, shown movement
It will be more smooth.In general, to avoid acting it is slack it is minimum be 30.Certain computer video formats, it is per second to provide 15
Frame.
The abbreviation of LOD-, that is, Levels of Detail, means detail.LOD technology refers to the section according to object model
Point is the location of in display environment and different degree, the resource allocation of decision object rendering reduce the face number of insignificant object
And degrees of detail, to obtain efficient rendering operation.
It show the method flow schematic diagram of preferred embodiment according to the present invention referring to Fig.1,
Model formulates step, and simultaneously each essence is arranged in the model gradually reduce at least two fineness of modelling in game
The corresponding transmission frame number per second of fineness, i.e. frame number grade;
In order to guarantee that the running equipment of various configurations is capable of the running game program of normal smoothness, first carries out model and formulate step
Suddenly, simplified or abundant details is carried out to existing model, the different model of multiple finenesses is obtained, according to the height of model fineness
Low that different FPS is successively arranged from high to low, this FPS is exactly frame number grade, and in general, model fineness is higher, corresponding
FPS require it is also higher.
Game monitoring step executes games, grabs the parameters in game running, and wherein parameter includes but unlimited
In transmission frame number per second;
In general, scheme there are many FPS in acquisition game,
1) passing through dumpsysSurfaceFlinger | grep flips order obtains the FPS of current system, if only
There is game process on foreground, can also get correct FPS information, the method is the simplest, without hook and inject etc..
2) by injection so to surfacelinger process, hook eglSwapBuffers function records the function tune
FPS information can also be obtained with frequency.
3) injection so loads script to target process, and in the unity gameobject of target process, records
The calling frequency of update obtains FPS.
The third is the most complicated, the first is the simplest, but highlight herein be exactly the third obtain FPS principle
And realize brief introduction.The reason for this is that: it, can be with other than available FPS by injecting so and cs script in target game process
Realize other more functions.
After so file is injected into target game process using inject, which calls mono relevant interface, and cs is compiled
Dll file afterwards is loaded into process, while calling gameobject.AddComponent method, this script is just added by dynamic
It is downloaded to game process to suffer, update and OnGUI in script etc. can be called by game process and be arrived, and only need to record update's
Call frequency that can obtain FPS information (UI can certainly be drawn in target game process).Step brief introduction prepare inject into
(then in target process application memory, and target process is written, at this in one section of machine instruction to journey by ATTACH to target process
Load so file to be implanted in machine instruction section);After So is loaded into target process, calls dlsym to obtain mono correlation and connect
Mouthful;Mono relevant interface is called to get the class information of the System.Reflection:Assembly in mscorlib, and
Obtain Load the and GetType method in the class;Mono relevant interface is called to obtain GameObject in UnityEngine
Class, and obtain ctor the and AddComponent method in the class;Dll after script file to be implanted is compiled
Binary content is all read in memory code_buffer;The Load method in 3 is called to be loaded into code_buffer content
Process;It can be by compile after load;The type information (calling the GetType in 3) of the class of main classes after obtaining load;
Call mono_object_new to create GameObject (using the class information got in 4);It calls
The object of creation is loaded into unity by AddComponent;
So far, script is loaded onto process and suffers, and the methods of update can be called in more new frame, then realizes one
A FPS calculator, so that it may get FPS.Above-mentioned 10 step needs are all realized in mono active thread, cannot injected
SO call initialization function in realize (because its call most of mono method all since mono thread local cache number
According to), the mode of mono thread is switched to by registering profiler (by calling mono_profiler_install and mono_
Profiler_install_method_invoke is realized).
Script is filled with to game process, which can interact with game UI, realize automatic test.
Running optimizatin step executes comparison according to transmission frame number per second and each frame number grade, and transmission frame number per second is big
In the model for being set as going game program display equal to the corresponding model of frame number grade;
For example, taking the game running time in one section of 10s, the FPS of 10s is obtained, average value processing is done, obtains this
The average FPS of 10s game is compared further according to the model fineness and corresponding frame number grade being arranged before, is such as provided with three
A model fineness LOD1, LOD2 and LOD3, wherein fineness is successively successively decreased, and is similarly also successively dropped to the consumption of the new energy of equipment
It is low;Corresponding three frame number grades FPS1, FPS2 of three model accuracies and FPS3, wherein numerical value successively successively decreases.
The size of average FPS and three frame number grade is judged, if average value is greater than FPS1, the mould that going game is shown
Type fineness is set as the corresponding model fineness of FPS1, i.e. LOD1.Preferably implementation is shown according to the present invention referring in particular to Fig. 2
The Optimization Steps flow diagram of example.
Game monitoring step and running optimizatin step are repeated, until games are out of service.
Entire Optimization Steps are all executing in game running, realize the real-time optimization to game.
Conclude explanation that is,
1. every frame calculates FPS, the calculation of FPS was 1 time undergone divided by previous frame to this frame.
2. 3 LOD ranks of the modelling of pair each object, LOD1, LOD2, LOD3.This 3 LOD ranks are according to mould
The fineness of type defines, and the fineness of LOD1, LOD2, LOD3 model are lower and lower, lower and lower to the consumption of performance.
3. defining 3 FPS ranks, FPS1, FPS2, FPS3.The lower trip of FPS1=45, FPS2=30, FPS3=20.FPS
Fluency of playing is poorer, illustrates that present performance pressures are bigger.This 3 FPS ranks correspond to corresponding model LOD rank.The number of FPS
The definition of value is according to the corresponding FPS numerical value of the high, normal, basic fluency of game acceptable.For example shooting game may overall number
Value is all higher, and the game of RPG class totally can be all more relatively low.
4. obtaining 1 FPS calculated in game running, the grade according to locating for FPS selects corresponding LOD rank.Than
If current FPS is 45 >=FPS1 select LOD1, current FPS is that FPS1 >=40 >=FPS2 then selects LOD2.
The system module block diagram of preferred embodiment according to the present invention is shown referring to Fig. 3, including
Model optimization module, model and setting for gradually being reduced at least two fineness of modelling in game
The corresponding transmission frame number per second of each fineness, i.e. frame number grade, further include model processing modules, for the face by reducing model
And number of grid is reduced to reduce the fineness of model;
Game monitoring modular grabs the parameters in game running for executing games;
Game optimization module, for executing comparison according to transmission frame number per second and each frame number grade, by transmission frame per second
Number is more than or equal to the model that the corresponding model of frame number grade is set as going game program display, frame number processing module, for obtaining
The transmission frame number per second in a period of time is taken, and does average treatment, frame number average value is obtained, wherein can customize for a period of time;
The frame number grade of judgment module, the frame number average value for will obtain and setting, which is compared one by one and made the difference, to take absolute value, and sentences
Whether disconnected frame number average value is greater than frame number grade, if then using the frame number grade of maximum absolute value as objective optimization frame number etc.
Grade, otherwise using the smallest frame number grade of absolute value as objective optimization frame number grade;Model setup module is used for objective optimization
The corresponding model of frame number grade is set as the model of going game program display;
Game process detection module for detecting whether games run, and sends to other modules according to result and examines
Survey order.
It should be appreciated that the embodiment of the present invention can be by computer hardware, the combination of hardware and software or by depositing
The computer instruction in non-transitory computer-readable memory is stored up to be effected or carried out.Standard volume can be used in the method
Journey technology-includes that the non-transitory computer-readable storage media configured with computer program is realized in computer program,
In configured in this way storage medium computer is operated in a manner of specific and is predefined --- according in a particular embodiment
The method and attached drawing of description.Each program can with the programming language of level process or object-oriented come realize with department of computer science
System communication.However, if desired, the program can be realized with compilation or machine language.Under any circumstance, which can be volume
The language translated or explained.In addition, the program can be run on the specific integrated circuit of programming for this purpose.
In addition, the operation of process described herein can be performed in any suitable order, unless herein in addition instruction or
Otherwise significantly with contradicted by context.Process described herein (or modification and/or combination thereof) can be held being configured with
It executes, and is can be used as jointly on the one or more processors under the control of one or more computer systems of row instruction
The code (for example, executable instruction, one or more computer program or one or more application) of execution, by hardware or its group
It closes to realize.The computer program includes the multiple instruction that can be performed by one or more processors.
Further, the method can be realized in being operably coupled to suitable any kind of computing platform, wrap
Include but be not limited to PC, mini-computer, main frame, work station, network or distributed computing environment, individual or integrated
Computer platform or communicated with charged particle tool or other imaging devices etc..Each aspect of the present invention can be to deposit
The machine readable code on non-transitory storage medium or equipment is stored up to realize no matter be moveable or be integrated to calculating
Platform, such as hard disk, optical reading and/or write-in storage medium, RAM, ROM, so that it can be read by programmable calculator, when
Storage medium or equipment can be used for configuration and operation computer to execute process described herein when being read by computer.This
Outside, machine readable code, or part thereof can be transmitted by wired or wireless network.When such media include combining microprocessor
Or other data processors realize steps described above instruction or program when, invention as described herein including these and other not
The non-transitory computer-readable storage media of same type.When methods and techniques according to the present invention programming, the present invention
It further include computer itself.
Computer program can be applied to input data to execute function as described herein, to convert input data with life
At storing to the output data of nonvolatile memory.Output information can also be applied to one or more output equipments as shown
Device.In the preferred embodiment of the invention, the data of conversion indicate physics and tangible object, including the object generated on display
Reason and the particular visual of physical objects are described.
The above, only presently preferred embodiments of the present invention, the invention is not limited to above embodiment, as long as
It reaches technical effect of the invention with identical means, all should belong to protection scope of the present invention.In protection model of the invention
Its technical solution and/or embodiment can have a variety of different modifications and variations in enclosing.