Summary of the invention
Technical matters to be solved by this invention is, a kind of timer cycle that browser is resolved layout of can supporting dynamically to set is provided, or, the embedded web page analytic method of the web data size that browser reads in described timer cycle and use the web browser and the terminal device of this method.
In order to solve above-mentioned technical matters,
At first, the invention provides a kind of embedded web page analytic method,, dynamically set the timer cycle that described browser is resolved layout according to the performance of system at that time, the difference of webpage complexity, or, dynamically set the web data size that described browser reads in timer cycle;
Wherein, described browser is resolved the timer cycle=current system performance of system timer cycle ÷ of layout; The web data size that web data size=system default that described browser reads in timer cycle reads * (system default is resolved in the required last timer cycle of time ÷ of layout default size web data and is resolved the time that layout consumed).
Further, the described system timer cycle is current timer cycle, or, initial timer cycle.
Further, the current parsing positioning efficiency ÷ of described current system performance=system system default is resolved positioning efficiency,
Wherein, the required time of web data that the described browser resolves of big or small ÷ of described parsing positioning efficiency=described browser resolves web data should size.
Secondly, the present invention also provides a kind of embedded web page to resolve browser, comprising:
Setting module is used for the difference of performance, webpage complexity according to system at that time and dynamically obtains and set the timer cycle that browser is resolved layout, or, dynamically set the web data size that browser reads in timer cycle;
Wherein, described setting module dynamically obtains browser timing cycle=current system performance of system timer cycle ÷; Described setting module dynamically obtains web data size * (system default is resolved the parsing time that layout consumed in required the last timer cycle of time ÷ of layout default size web data) that web data size=system default that browser reads reads in timer cycle.
Wherein, the described system timer cycle is current timer cycle, or, initial timer cycle;
The described current system performance=current parsing positioning efficiency ÷ of described system system default is resolved positioning efficiency; The described browser resolves of big or small ÷ of described parsing positioning efficiency=described browser resolves web data should size the required time of web data.
At last, the present invention also provides a kind of terminal device, comprises web browser, and described web browser comprises:
Setting module is used for the difference of performance, webpage complexity according to system at that time and dynamically obtains and set the timer cycle that browser is resolved layout, or, the web data size that browser reads in timer cycle;
Wherein, described setting module dynamically obtains browser timing cycle=current system performance of system timer cycle ÷; Described setting module dynamically obtains web data size * (system default is resolved the parsing time that layout consumed in required the last timer cycle of time ÷ of layout default size web data) that web data size=system default that browser reads reads in timer cycle.
Wherein, the described system timer cycle is current timer cycle, or, initial timer cycle;
The described current system performance=current parsing positioning efficiency ÷ of described system system default is resolved positioning efficiency; The described browser resolves of big or small ÷ of described parsing positioning efficiency=described browser resolves web data should size the required time of web data.
By implementing the present invention, overcome the timer cycle of resolving layout in traditional embedded web page analytic method because of browser, or, web data that browser reads in described timer cycle size is set unreasonable and the system resource waste that causes and the generation of various error situations, thereby improved browser and carried out the webpage analytic efficiency, strengthened the experience the when user passes through the mobile terminal accessing the Internet.
Embodiment
Basic ideas of the present invention are, browser is resolved the timer cycle of layout and do not fixed, but according to differences such as the performance of system at that time, webpage complexities and dynamic calculation; Equally, the big or small x that browser reads web data in each timer cycle the inside neither rule of thumb be worth the constant of setting, but will dynamically calculate and obtain the size that browser next time reads web data according to the efficient of browser resolves layout in the last timer cycle.
Below in conjunction with accompanying drawing treatment scheme involved in the present invention etc. is described in detail:
1, abbreviation explanation
T: browser periodically reads web data from procotol, resolves the time interval of operations such as layout.This value sets in advance in the prior art, obtains by dynamic calculation in the present invention;
TS: the initial value of above-mentioned T, promptly browser starts for the first time, the value of the back T that perhaps resets, this value can set in advance or set by other modes.
X: in each timer cycle, browser is wished the size of data that reads from procotol.
X: in each timer cycle, the size of data that browser reality reads from procotol.Owing to reasons such as networks, the actual size of data x that reads from procotol is generally less than and equals to wish the size of data X that reads from procotol.
TA: browser is resolved layout size and is the time that the general complexity web data of X consumed (begin from parsing finish to layout time) under all normal situation of system and network.
2, initialization operation
(comprise that browser starts for the first time when initial, situations such as it is back perhaps to reset) the timer cycle TS of browser resolves layout, and the next timer cycle of the normal situation of, network condition normal in system performance wishes to resolve the big or small X of the web data of the general complexity of layout, can rule of thumb choose according to the hardware and software difference (as the dominant frequency frequency of CPU) of system.Resolving the time T A that the general webpage of the X of layout size consumes under system's normal condition then can obtain by the reality test: some routines, webpage commonly used calculate parsings, layout webpage size is the time of data institute's expense under this built-in browser of X such as visiting in the ordinary course of things by this terminal system browser, general calculate several times, the office's value of making even then just obtains TA more.
Certainly, the initial timer cycle TS of timer, the big or small X that at every turn reads webpage also can be optimized according to the actual conditions of embedded system.Such as, it is 50~200ms that the TS scope can be set, with stepping is 10, be set to parameter TS=50+n * 10 (49<T<201, n gets the integer since 0), the same scope that X is set is 512~2048byte, with 20 is stepping, be set to parameter X=512+m * 20 (519<X<2049, m gets the integer since 0), calculate the TA value by top method.Design program according to method of the present invention then, allow one group of tester that parameter TS, the X effect of browser are tested and assessed, choose best one group of effect TS and X parameter are set, the TS that obtains like this, X and TA are exactly at this software, hardware system best parameter comparatively speaking.
Provide a reference data below:
CPU? |
Dominant frequency (mHZ) |
TS(ms)? |
X(byte)? |
TA(ms)? |
ARM9? |
?100? |
100? |
1024? |
30? |
ARM9? |
?200? |
60? |
1024? |
15? |
ARM11? |
?300? |
80? |
2048? |
25? |
2, embodiment 1
As shown in Figure 1, be only to adopt when dynamically setting timer cycle the operating process of method that the present invention comprises:
101: timer cycle arrives;
102: browser reads the web data that is X to the maximum from procotol, but owing to reasons such as network data also are not ready for, the actual data x that reads should be able to then be provided with the size of x=actual read data smaller or equal to X;
103~106: if x<the 0 then explanation browser reads webpage makes a mistake, this might be that the network reason causes, also might be because system's reason cause, and this flow process finishes, and forwards 113 to; Otherwise change 107;
107: browser obtains current system time Ta;
108: browser carries out parse operation;
109: browser carries out the layout operation;
110: browser obtains current system time Tb;
111: it is the time t=Tb-Ta that web data consumed of x that browser calculates this parsing layout size;
112: browser calculates next time the timer cycle T=(÷ of TS * X * t) (TA * x);
113: browser is reset next timer (cycle is T), finishes this flow process.
Browser repeats above-mentioned flow process, resolves layout until webpage and finishes or situation such as user's interrupt operation takes place and finish whole browsing page operation.
Certainly, calculate timer cycle next time at browser, also can adopt the current timer cycle of system to replace initial timer cycle, be i.e. the T=(÷ of T * X * t) (TA * x), thereby further improve the dynamic of timer cycle value, improve system performance.
3, embodiment 2
As shown in Figure 2, be only to adopt when dynamically setting the size of data that browser reads in the timer cycle from procotol the operating process of method that the present invention comprises:
201: timer cycle arrives;
202: calculate web data size X=TA * (the x ÷ t) that this timer cycle need read; If system starts for the first time or other reasons is restarted, t=TA, X gets system default value;
203: browser reads the web data that is x to the maximum from procotol.Owing to reasons such as network data also are not ready for, the actual data that read should be smaller or equal to x; If the actual data that read, then are provided with the size of x for this actual read data less than x;
204~207: if x<the 0 then explanation browser reads webpage makes a mistake, this might be that the network reason causes, also might be because system's reason cause, and this flow process finishes, and forwards 213 to; Otherwise change 208;
208: browser obtains current system time Ta;
209: browser carries out parse operation;
210: browser carries out the layout operation;
211: browser obtains current system time Tb;
212: it is the time t=Tb-Ta that web data consumed of x that browser calculates this parsing layout size;
213: timer cycle finishes.
Browser repeats above-mentioned flow process, resolves layout until webpage and finishes or situation such as user's interrupt operation takes place and finish whole browsing page operation.
4, embodiment 3
As shown in Figure 3, be when adopting the size of data that browser reads in the dynamic setting timer cycle simultaneously and dynamically setting timer cycle from procotol, the operating process of method that the present invention comprises:
301: timer cycle arrives;
202: calculate web data size X=TA * (the x ÷ t) that this timer cycle need read;
303: browser reads the web data that is X to the maximum from procotol, but owing to reasons such as network data also are not ready for, the actual data x that reads should be able to then be provided with the size of x=actual read data smaller or equal to X;
304~307: if x<the 0 then explanation browser reads webpage makes a mistake, this might be that the network reason causes, also might be because system's reason cause, and this flow process finishes, and forwards 113 to; Otherwise change 107;
308: browser obtains current system time Ta;
309: browser carries out parse operation;
310: browser carries out the layout operation;
311: browser obtains current system time Tb;
312: it is the time t=Tb-Ta that web data consumed of x that browser calculates this parsing layout size;
313: browser calculates next time the timer cycle T=(÷ of TS * X * t) (TA * x);
314: browser is reset next timer (cycle is T), finishes this flow process.
Browser repeats above-mentioned flow process, resolves layout until webpage and finishes or situation such as user's interrupt operation takes place and finish whole browsing page operation.
Certainly, calculate timer cycle next time at browser, also can adopt the current timer cycle of system to replace initial timer cycle, be i.e. the T=(÷ of T * X * t) (TA * x), thereby further improve the dynamic of timer cycle value, improve system performance.
5, embodiment 4
As shown in Figure 4, be the structural drawing of web browser provided by the invention, wherein:
Setting module: be used for the difference of performance, webpage complexity and dynamically obtain and set the timer cycle that browser is resolved layout according to system at that time, or, the web data size that browser reads in timer cycle;
Specifically in webpage is resolved layout process, when browser is set at dynamic setting and resolves the timer cycle of layout:
After timer cycle arrives, browser changes interpretive model over to by downloading mode, browser reads the web data that is X to the maximum from procotol, but owing to reasons such as network data also are not ready for, the actual data x that reads should be able to then be provided with the size of x=actual read data smaller or equal to X.
Subsequently, browser promptly begins the web pages downloaded data are resolved layout after writing down at that time system time Ta for the first time, after finishing, browser writes down system time Tb at that time once more, and going out this according to the Time Calculation of twice record, to resolve layout size be the time t that web data consumed of x;
Resolve after the layout operation finishes, the setting module in the browser calculates next time the timer cycle T=(÷ of TS * X * t) (TA * x), and reset next timer of browser.Certainly, as a kind of replacement scheme, browser also can adopt the current timer cycle of system to replace initial timer cycle, promptly T=(÷ of T * X * t) (and TA * x), thus further improve the dynamic of timer cycle value, improve system performance.
This timer arrives, and this is resolved the layout operating process and finishes.
Browser repeats above-mentioned flow process, resolves layout until webpage and finishes or situation such as user's interrupt operation takes place and finish whole browsing page operation.
When browser is set at the web data size that dynamic setting browser reads in timer cycle:
After timer cycle arrived, browser at first calculated web data size X=TA * (the x ÷ t) that this timer cycle need read.
Subsequently, browser reads the web data that is X to the maximum from procotol, but owing to reasons such as network data also are not ready for, the actual data x that reads should be able to then be provided with the size of x=actual read data smaller or equal to X.
Read finish after, browser promptly begins the web pages downloaded data are resolved layout after writing down at that time system time Ta for the first time, after finishing, browser writes down system time Tb at that time once more, and going out this according to the Time Calculation of twice record, to resolve layout size be the time t that web data consumed of x;
This timer arrives, and this is resolved the layout operating process and finishes.
Browser repeats above-mentioned flow process, resolves layout until webpage and finishes or situation such as user's interrupt operation takes place and finish whole browsing page operation.
6, embodiment 5
A mobile phone wherein includes web browser, when it carries out web page browsing, when the setting state of the web browser that it comprised is resolved the timer cycle of layout for dynamically setting:
After timer cycle arrives, browser in the mobile phone changes interpretive model over to by downloading mode, browser reads the web data that is X to the maximum from procotol, but owing to reasons such as network data also are not ready for, the actual data x that reads should be able to then be provided with the size of x=actual read data smaller or equal to X.
Subsequently, browser promptly begins the web pages downloaded data are resolved layout after writing down at that time system time Ta for the first time, after finishing, browser writes down system time Tb at that time once more, and going out this according to the Time Calculation of twice record, to resolve layout size be the time t that web data consumed of x;
Resolve after the layout operation finishes, the setting module in the browser calculates next time the timer cycle T=(÷ of TS * X * t) (TA * x), and reset next timer of browser.Certainly, as a kind of replacement scheme, browser also can adopt the current timer cycle of system to replace initial timer cycle, promptly T=(÷ of T * X * t) (and TA * x), thus further improve the dynamic of timer cycle value, improve system performance.
This timer arrives, and this is resolved the layout operating process and finishes.
Browser repeats above-mentioned flow process, resolves layout until webpage and finishes or situation such as user's interrupt operation takes place and finish whole browsing page operation.
When the setting state of it being said the web browser that is comprised during for the web data size dynamically setting browser and in timer cycle, read:
After timer cycle arrived, the browser in the mobile phone at first calculated web data size X=TA * (the x ÷ t) that this timer cycle need read.
Subsequently, browser reads the web data that is X to the maximum from procotol, but owing to reasons such as network data also are not ready for, the actual data x that reads should be able to then be provided with the size of x=actual read data smaller or equal to X.
Read finish after, browser promptly begins the web pages downloaded data are resolved layout after writing down at that time system time Ta for the first time, after finishing, browser writes down system time Tb at that time once more, and going out this according to the Time Calculation of twice record, to resolve layout size be the time t that web data consumed of x;
This timer arrives, and this is resolved the layout operating process and finishes.
Browser repeats above-mentioned flow process, resolves layout until webpage and finishes or situation such as user's interrupt operation takes place and finish whole browsing page operation.
We know that the factor that influences system performance in embedded system also has a lot, and the temperature that causes as long-time use CPU raises, and CPU efficient reduces; Internal memory reduces, perhaps the increase of memory fragmentation increase internal memory application release time of causing; Wireless network complexity, network data need repeatedly to retransmit the transmitting-receiving that just can finish data, cause procotol to take more cpu resource; And whether webpage have factors such as CSS, Javascript all can cause the onesize web data of browser resolves, and the time difference of consumption is very big.Therefore, the above embodiment is the preferred embodiments of the present invention only, is not limited to the present invention, and for a person skilled in the art, the present invention can have various changes and variation.Within the spirit and principles in the present invention all, any modification of being done, be equal to replacement, improvement etc., all should be included within protection scope of the present invention.