CN106814789A - A kind of clocking method and device - Google Patents
A kind of clocking method and device Download PDFInfo
- Publication number
- CN106814789A CN106814789A CN201710060613.8A CN201710060613A CN106814789A CN 106814789 A CN106814789 A CN 106814789A CN 201710060613 A CN201710060613 A CN 201710060613A CN 106814789 A CN106814789 A CN 106814789A
- Authority
- CN
- China
- Prior art keywords
- timer
- timing
- time
- timer time
- system timer
- 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.)
- Granted
Links
Classifications
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F1/00—Details not covered by groups G06F3/00 - G06F13/00 and G06F21/00
- G06F1/04—Generating or distributing clock signals or signals derived directly therefrom
- G06F1/14—Time supervision arrangements, e.g. real time clock
Abstract
This application discloses a kind of clocking method and device, when it is determined that reaching setting timing and starting condition, the timer time of system timer is obtained, as the first timer time;When it is determined that reaching setting timing termination condition, the timer time of the system timer is obtained, as the second timer time;It is determined that since reach setting timing the condition moment to reach setting the timing termination condition moment during, the replacement number of times of the system timer;Calculate the difference that second timing result subtracts first timing result, and it is described reset number of times and the system timer time-count cycle value product, and by the difference and the product and value be defined as timing result.On-demand system timer resets repeatedly in timing course, and the application still is able to determine correct timing result, and need not restart system, it is ensured that the normal operation of business.
Description
Technical field
The application is related to timer technique field, more specifically to a kind of clocking method and device.
Background technology
During service operation, it is sometimes desirable to which service operation duration is counted.Existing clocking method is generally comprised
Two kinds, one kind is call operation system time to be counted to service operation duration.But, the precision of operating system time has
Limit, the business higher for time precision requirement cannot meet.
Therefore, system provides another clocking method, i.e., timing statistics is carried out by the timer that system is carried.System
The accuracy of timekeeping of timer is significantly larger than the operating system time.By taking target service run time timing course as an example, in target industry
Business Startup time obtains the timer time of system timer, and system timer is obtained again at the target service end of run moment
Timer time, and the timer time of first acquisition is subtracted using the timer time in rear acquisition, as a result as the fortune of target service
The row time.
But, system timer generally there are time-count cycle, and system timer is since after timing arrival value time-count cycle 0
0, and the timing again since 0 can be reset to.The size of time-count cycle is limited by the storage of timing numerical value, with Windows systems
Illustrated as a example by timer, its timing numerical value is the double word type DWORD storages of 32, the greatest measure that can be stored is (2
^32-1) ms, about 49.71 days.That is, value time-count cycle of Windows system timers is 49.71 days, timer time is reached
The time-count cycle will reset to 0 and the timing since 0 again after value.
Still by taking target service run time timing course as an example, if the front and rear timer time for obtaining system timer twice
Between, system timer there occurs replacement operation, then the abnormal situation of timing result occurs.Such as the timer time for formerly obtaining
It is 49 days, is 1 day in the timer time of rear acquisition, the timing result after subtracting each other is negative.As a example by avoid the hair of such case
Raw, prior art is usually before the timer time of system timer soon reaches value time-count cycle, to restart system.But,
This processing mode meeting traffic affecting normally runs.
The content of the invention
In view of this, this application provides a kind of clocking method and device, to solve prior art to prevent system timing
Device resets brought timing result exception in timing course, using the reduction business restarted caused by the solution of system
The problem of uptime.
To achieve these goals, it is proposed that scheme it is as follows:
A kind of clocking method, including:
It is determined that reach setting timing start condition when, obtain system timer timer time, during as the first timing
Carve;
When it is determined that reaching setting timing termination condition, the timer time of the system timer is obtained, as the second meter
When the moment;
It is determined that since reach setting timing the condition moment to reach setting the timing termination condition moment during, it is described
The replacement number of times of system timer;
Calculate the difference that second timer time subtracts first timer time, and the replacement number of times with it is described
System timer time-count cycle value product, and by the difference and the product and value be defined as timing result.
A kind of time set, including:
First timer time acquiring unit, for it is determined that reach setting timing start condition when, obtain system timer
Timer time, as the first timer time;
Second timer time acquiring unit, for when it is determined that reaching setting timing termination condition, obtaining the system meter
When device timer time, as the second timer time;
Number of times determining unit is reset, for determining to terminate since the condition moment reaching setting timing to setting timing is reached
During the condition moment, the replacement number of times of the system timer;
Timing result determining unit, the difference of first timer time is subtracted for calculating second timer time,
And it is described reset number of times and the system timer time-count cycle value product, and by the difference and the product and
Value is defined as timing result.
The embodiment of the present application provide clocking method, it is determined that reach setting timing start condition when, obtain system timing
The timer time of device, as the first timer time;When it is determined that reaching setting timing termination condition, the system timer is obtained
Timer time, as the second timer time;It is determined that terminating since the condition moment reaching setting timing to setting timing is reached
During the condition moment, the replacement number of times of the system timer;Calculate second timing result and subtract first meter
When result difference, and it is described reset number of times and the system timer time-count cycle value product, and by the difference
With the product and value be defined as timing result.It follows that determined in the application since reach setting timing condition
Moment to reach setting the timing termination condition moment during, the replacement number of times of system timer, and and then calculate second
Timing result is subtracted on the basis of the difference of the first timing result, further calculates the meter of the replacement number of times and system timer
When periodic quantity product, the difference and the addition result of the product are defined as timing result, on-demand system timer exists
Reset repeatedly in timing course, the application still is able to determine correct timing result, and need not restart system, it is ensured that business
Normal operation.
Brief description of the drawings
In order to illustrate more clearly of the embodiment of the present application or technical scheme of the prior art, below will be to embodiment or existing
The accompanying drawing to be used needed for having technology description is briefly described, it should be apparent that, drawings in the following description are only this
The embodiment of application, for those of ordinary skill in the art, on the premise of not paying creative work, can also basis
The accompanying drawing of offer obtains other accompanying drawings.
Fig. 1 is a kind of clocking method flow chart disclosed in the embodiment of the present application;
Fig. 2 is another clocking method flow chart disclosed in the embodiment of the present application;
Fig. 3 is a kind of target game technical ability cool time statistical method flow chart disclosed in the embodiment of the present application;
Fig. 4 is another clocking method flow chart disclosed in the embodiment of the present application;
Fig. 5 is a kind of time set structural representation disclosed in the embodiment of the present application;
A kind of service end hardware architecture diagram that Fig. 6 is provided for the embodiment of the present application.
Specific embodiment
Below in conjunction with the accompanying drawing in the embodiment of the present application, the technical scheme in the embodiment of the present application is carried out clear, complete
Site preparation is described, it is clear that described embodiment is only some embodiments of the present application, rather than whole embodiments.It is based on
Embodiment in the application, it is every other that those of ordinary skill in the art are obtained under the premise of creative work is not made
Embodiment, belongs to the scope of the application protection.
The embodiment of the present application discloses a kind of clocking method, can apply to service end or terminal, for service end or
Business in terminal carries out timing statistics.Wherein, business can include polytype, by taking game service as an example, can be to game
The technical ability cd times carry out timing statistics, carry out timing statistics to the brush strange time, carry out timing statistics etc. to the ludic activity time.
It is understood that application scheme goes for the various fields that timing duration is shorter and timing duration is more long
Scape.In ensuing embodiment, the clocking method to the embodiment of the present application is introduced, shown in Figure 1, and the method includes:
Step S100, when it is determined that reaching setting timing and starting condition, the timer time of system timer is obtained, as the
One timer time;
Specifically, the application can be counted to the time-consuming duration of various different business, operation.Only need to preset
Good timing starts condition and timing termination condition.Wherein, set timing and start condition to start timer time, setting meter
When termination condition for terminate timer time.
By taking the operation timing statistics to target service as an example, then set timing and start condition as target service starts to start,
Set timing termination condition as target service end of run.
In this step, when it is determined that reaching setting timing and starting condition, the timer time of system timer is obtained, as the
One timer time.Wherein, system timer can be equivalent to a clock and watch, it is determined that reaching setting timing starts bar in this step
During part, the timer time at system timer current time is obtained, as the first timer time.
By taking the operation timing statistics of target service as an example, example is as follows:
When it is determined that target service starts to start, the first timer time of system timer is obtained:50ms.That is, mesh
Mark business starts to start at the 50ms moment.
Step S110, when it is determined that reaching setting timing termination condition, obtain the timer time of the system timer, make
It is the second timer time;
Specifically, it is general, reach setting timing start moment of condition with reach setting timing termination condition when
Quarter is two different moment.In this step, when it is determined that reaching setting timing termination condition, system timer is obtained again
Timer time, as the second timer time.
It is understood that the sequencing developed according to the time, reaching the setting timing termination condition moment should be later than and reach
Start the condition moment to setting timing.But, replacement can be produced reaching time-count cycle due to system timer after value, therefore the
Magnitude relationship between two timer times and the first timer time is not fixed.
Still by taking the operation timing statistics of target service as an example, example is as follows:
It is determined that during target service end of run, obtaining the second timer time of system timer:80ms.That is, mesh
Mark business is in 80ms moment end of runs.
It is understood that target service is probably to be brought into operation from 50ms, and run end of run after 30ms.Except this
Outside, target service be also possible to be brought into operation from 50ms, and be added time-count cycle one or more system timers are run
End of run after 30ms.
Step S120, determination are since the condition moment reaching setting timing to the mistake for reaching the setting timing termination condition moment
Cheng Zhong, the replacement number of times of the system timer;
Specifically, specifically, the condition moment since setting timing is reached is determined in this step, timing knot is set to reaching
During the beam condition moment, the replacement number of times of system timer.Wherein, the replacement number of times of system timer is system timing
Think highly of the number of times for being set to 0.
Step S130, calculating second timer time subtract the difference of first timer time, and the replacement
Number of times and the system timer time-count cycle value product, and by the difference and the product and value be defined as timing
As a result.
It can be seen from above-mentioned introduction, if reaching the moment that setting timing starts condition, bar is terminated with setting timing is reached
The moment of part was in same system timer time-count cycle, then can determine that system timer resets time in this process
Number is 0, then the difference for subtracting the first timer time the second timing quarter is last timing result.But, if reaching setting
Timing starts the moment of condition, and same system timer time-count cycle is not in the moment for reaching setting timing termination condition
It is interior, then need on the basis of calculating second timer time subtracts the difference of first timer time, further calculate
It is described reset number of times and the system timer time-count cycle value product, and by the difference and the product and be worth really
It is set to timing result.
The first timer time is defined for lastTick, the second timer time is curTick, replacement number of times is n, system timing
Value time-count cycle of device is T, then timing result delayTick can be determined by following formula:
DelayTick=curTick-lastTick+n*T
It was determined that when n is 0, i.e., it is 0 that system timer resets number of times, the moment that setting timing starts condition is reached,
It is in same system timer time-count cycle with the moment for reaching setting timing termination condition, now, delayTick=
curTick-lastTick。
The embodiment of the present application provide clocking method, it is determined that reach setting timing start condition when, obtain system timing
The timer time of device, as the first timer time;When it is determined that reaching setting timing termination condition, the system timer is obtained
Timer time, as the second timer time;It is determined that terminating since the condition moment reaching setting timing to setting timing is reached
During the condition moment, the replacement number of times of the system timer;Calculate second timing result and subtract first meter
When result difference, and it is described reset number of times and the system timer time-count cycle value product, and by the difference
With the product and value be defined as timing result.It follows that determined in the application since reach setting timing condition
Moment to reach setting the timing termination condition moment during, the replacement number of times of system timer, and and then calculate second
Timing result is subtracted on the basis of the difference of the first timing result, further calculates the meter of the replacement number of times and system timer
When periodic quantity product, the difference and the addition result of the product are defined as timing result, on-demand system timer exists
Reset repeatedly in timing course, the application still is able to determine correct timing result, and need not restart system, it is ensured that business
Normal operation.
In another embodiment of the application, illustrated by taking the operation timing statistics to target service as an example.Then set
Start condition during devise a stratagem for target service starts to start, set timing termination condition as target service end of run.The present embodiment
In, it is assumed that the maximum operation duration of target service, for such target service, is carried no more than value time-count cycle of system timer
A kind of clocking method is supplied, referring to Fig. 2, Fig. 2 is another clocking method flow chart disclosed in the embodiment of the present application, such as Fig. 2 institutes
Show, the method includes:
Step S200, it is determined that target service start start when, obtain system timer timer time, as first meter
When the moment;
Specifically, timing is set in the present embodiment and starts condition as target service starts to start, wherein target service is true
Carry out running the business of timing statistics the need for fixed.
Step S210, it is determined that during target service end of run, obtain the timer time of the system timer, as the
Two timer times;
Specifically, timing termination condition as target service end of run is set in the present embodiment.
Step S220, judge second timer time whether no more than first timer time;If so, performing step
S230, if it is not, performing step S240;
Specifically, foregoing by the agency of, the maximum operation duration of target service is no more than system counter in the present embodiment
Value time-count cycle, therefore, only can exist two kinds of situations, when one kind is target service Startup time and target service end of run
Carve within same time-count cycle, it is 0 that system timer resets number of times;Another situation is target service Startup time and target
Service operation finish time is in two different time-count cycles, and two time-count cycles are two adjacent time-count cycles, are
Think highly of during statistics and put number of times for 1.
For the first situation, the second timer time of acquisition is more than the first timer time.For second situation, obtain
The second timer time be no more than the first timer time.
In this step, by judging the second timer time whether no more than the first timer time, it may be determined that target service
Startup time and target service end of run moment, whether within same time-count cycle it was 0 that is, system timer resets number of times
Or be 1.
Step S230, to determine that the system timer resets number of times be 1;
Specifically, when judging that the second timer time is no more than first timer time, then target service can be determined
Startup time and target service end of run moment were respectively in two neighboring different time-count cycles, i.e., system timer resets
Number of times is 1.
Step S240, to determine that the system timer resets number of times be 0;
Specifically, when judging that the second timer time exceedes first timer time, then can determine that target service is opened
Dynamic moment and target service end of run moment were in same time-count cycle, i.e., it is 0 that system timer resets number of times.
Step S250, calculating second timer time subtract the difference of first timer time, and the replacement
Number of times and the system timer time-count cycle value product, and by the difference and the product and value be defined as timing
As a result.
Specifically, when it is determined that system timer reset number of times be 1 when, then the expression formula of timing result is as follows:
DelayTick=curTick-lastTick+T
When it is determined that system timer reset number of times be 0 when, then the expression formula of timing result is as follows:
DelayTick=curTick-lastTick
In the present embodiment, the target service of the time-count cycle of system timer, Ke Yitong are less than for maximum operation duration
Such scheme is crossed accurately and rapidly to determine the operation duration of target service.
So that target service is game skill cool time cd as an example, due to game skill cool time it is general at several seconds or
Within a few minutes, far smaller than system timer time-count cycle (time-count cycle of system timer is generally one month or so,
By taking Windows system timers as an example, its time-count cycle is 49.7 days).Referring to Fig. 3, Fig. 3 illustrates a kind of target game technical ability
Cool time statistical method flow chart, as shown in figure 3, the process can include:
Step S300, when it is determined that target game technical ability starts release, the timer time of system timer is obtained, as the
One timer time;
Specifically, the release conditions of target game technical ability can be monitored in this step, then detects target game
When technical ability starts release, the timer time of system timer is obtained, as the first timer time.
Step S310, at the end of it is determined that target game technical ability is cooled down, obtain the timer time of the system timer, make
It is the second timer time;
Specifically, the state of cooling is entered after the release of target game technical ability.Target game technical ability is detected in previous step
After release, persistently the state of cooling to the target game technical ability is monitored, then at the end of detecting the cooling of target game technical ability,
The timer time of system timer is obtained again, as the second timer time.
Step S320, judge second timer time whether no more than first timer time;If so, performing step
S330, if it is not, performing step S340;
Step S330, to determine that the system timer resets number of times be 1;
Step S340, to determine that the system timer resets number of times be 0;
Step S350, calculating second timer time subtract the difference of first timer time, and the replacement
Number of times and the system timer time-count cycle value product, and by the difference and the product and value be defined as it is described
The cool time of target game technical ability.
Through the above way, for the game skill that cool time is shorter, its actual cool time can quickly be determined.
Certainly, above-described embodiment is only illustrated by taking game skill cool time as an example, and other run times are no more than
The business of the time-count cycle of system timer, it is also possible to determined using aforesaid way.
In another embodiment of the application, another realization side for determining that system timer resets number of times is described
Formula, referring to Fig. 4, Fig. 4 is another clocking method flow chart disclosed in the embodiment of the present application, as shown in figure 4, the method includes:
Step S400, when it is determined that reaching setting timing and starting condition, the timer time of system timer is obtained, as the
One timer time;
Step S410, when it is determined that reaching setting timing termination condition, obtain the timer time of the system timer, make
It is the second timer time;
Wherein, the process of step S400-S410 is identical with the process of step S100-S110 in previous embodiment, specifically may be used
So that with reference to foregoing description, here is omitted.
Step S420, acquisition monitoring thread reset the monitored results of number of times to the system timer;
Wherein, the monitored results include that the monitoring thread is set to reaching at the condition moment since reach setting timing
During devise a stratagem during the termination condition moment, the system timer for being monitored resets to 0 number of times.
The application can set a monitoring thread, by since reach setting timing the condition moment to reach setting based on
When the termination condition moment during, the replacement number of times to system timer is monitored.In this process, whenever it is determined that system
When timer resets, number of times will be reset and add 1 (reset number of times initial value be 0), obtain the total of system timer during this
Reset number of times.
Step S430, the replacement number of times that the system timer is determined according to the monitored results;
Step S440, calculating second timer time subtract the difference of first timer time, and the replacement
Number of times and the system timer time-count cycle value product, and by the difference and the product and value be defined as timing
As a result.
The scheme that the present embodiment is provided, can not only be applied to timing of the maximum run time no more than system timer
The business in cycle, the business that the time-count cycle of system timer is exceeded for maximum run time can also be applicable, by being
The replacement number of times of timer of uniting is monitored, it may be determined that at the condition moment since reach setting timing to reaching setting timing
During the termination condition moment, the replacement number of times of system timer, and then using resetting number of times and be calculated the operation of business
Timing result.
In another embodiment of the application, said so that system timer is for the timer of Windows systems as an example
Bright, in above-described embodiment, S100, it is determined that when reaching setting timing and starting condition, obtaining the timer time of system timer, makees
It is the process of the first timer time, and S110, when it is determined that reaching setting timing termination condition, obtain the system timer
Timer time, be introduced as the process of the second timer time.
The GetTickCount functions that can be provided by Windows systems in the present embodiment obtain system timer
Timer time.Therefore, above-mentioned steps S100 implements process and can include:
It is determined that reach setting timing start condition when, call GetTickCount functions obtain the first timer time.
Above-mentioned steps S110's implements process and can include:
When it is determined that reaching setting timing termination condition, when calling GetTickCount functions to obtain the second timing again
Carve.
Certainly, in the present embodiment only by taking the timer of Windows systems as an example, the meter for obtaining system timer is described
When the moment specific implementation.For other system timers, timer time can be obtained using corresponding method.
The time set that the embodiment of the present application is provided is described below, time set described below with it is described above
Clocking method can be mutually to should refer to.
Referring to Fig. 5, Fig. 5 is a kind of time set structural representation disclosed in the embodiment of the present application, as shown in figure 5, the dress
Put including:
First timer time acquiring unit 11, for it is determined that reach setting timing start condition when, obtain system timing
The timer time of device, as the first timer time;
Second timer time acquiring unit 12, for when it is determined that reaching setting timing termination condition, obtaining the system
The timer time of timer, as the second timer time;
Number of times determining unit 13 is reset, for determining to set timing knot from the condition moment reaching setting timing to reaching
During the beam condition moment, the replacement number of times of the system timer;
Timing result determining unit 14, the difference of first timer time is subtracted for calculating second timer time
Value, and it is described reset number of times and the system timer time-count cycle value product, and by the difference and the product
And value be defined as timing result.
The application provide time set, it is determined that since reach setting timing the condition moment to reach setting timing knot
During the beam condition moment, the replacement number of times of system timer, and and then subtract the first timing the second timing result is calculated
On the basis of the difference of result, further calculate replacement number of times and the system timer time-count cycle value product, by institute
State difference and be defined as timing result with the addition result of the product, on-demand system timer resets repeatedly in timing course,
The application still is able to determine correct timing result, and need not restart system, it is ensured that the normal operation of business.
Optionally, the setting timing starts condition can start to start including target service, and the setting timing terminates
Condition can include the target service end of run, wherein the target service is that operation timing statistics is carried out the need for determining
Business.
Further, if the maximum operation duration of the target service is no more than value time-count cycle of the system timer,
Then the application describes a kind of alternative construction for resetting number of times determining unit, and the replacement number of times determining unit can include:
Whether first resets number of times determination subelement, for judging second timer time no more than first timing
Moment, if, it is determined that it is 1 that the system timer resets number of times, otherwise, it determines it is 0 that the system timer resets number of times.
Optionally, the embodiment of the present application describes another alternative construction for resetting number of times determining unit, and it can include:
Second resets number of times determination subelement, resets the monitoring of number of times to the system timer for obtaining monitoring thread
As a result, the monitored results include the monitoring thread since reach setting timing the condition moment to reach setting timing knot
During the beam condition moment, the system timer for being monitored resets to 0 number of times;
3rd resets number of times determination subelement, the replacement time for determining the system timer according to the monitored results
Number.
Optionally, the system timer can be the timer of Windows systems.On this basis, first meter
When moment acquiring unit can include:
First function call unit, for it is determined that reach setting timing start condition when, call GetTickCount letters
Number obtains the first timer time;
The second timer time acquiring unit can include:
Second function call unit, for when it is determined that reaching setting timing termination condition, calling again
GetTickCount functions obtain the second timer time.
The time set of the application can apply to service end, such as game server, and time set can be to service end
Service operation duration counted.Certainly, time set can also be applied to user terminal, with to the business performed in terminal
Carry out operation duration statistics.By taking service end as an example, in ensuing embodiment, the service end of the time set to realizing the application
Hardware configuration be introduced, referring to Fig. 6, a kind of service end hardware architecture diagram that Fig. 6 is provided for the embodiment of the present application.
As shown in fig. 6, service end can include:
Processor 1, communication interface 2, memory 3, communication bus 4, and display screen 5;
Wherein processor 1, communication interface 2, memory 3 and display screen 5 complete mutual communication by communication bus 4;
Optionally, communication interface 2 can be the interface of communication module, such as interface of gsm module;
Processor 1, for configuration processor;
Memory 3, for depositing program;
Program can include program code, and described program code includes the operational order of processor.
Processor 1 is probably a central processor CPU, or specific integrated circuit ASIC (Application
Specific Integrated Circuit), or it is arranged to implement one or more integrated electricity of the embodiment of the present application
Road.
Memory 3 may include high-speed RAM memory, it is also possible to also including nonvolatile memory (non-volatile
Memory), for example, at least one magnetic disk storage.
Wherein, program specifically for:
It is determined that reach setting timing start condition when, obtain system timer timer time, during as the first timing
Carve;
When it is determined that reaching setting timing termination condition, the timer time of the system timer is obtained, as the second meter
When the moment;
It is determined that since reach setting timing the condition moment to reach setting the timing termination condition moment during, it is described
The replacement number of times of system timer;
Calculate the difference that second timer time subtracts first timer time, and the replacement number of times with it is described
System timer time-count cycle value product, and by the difference and the product and value be defined as timing result.
Finally, in addition it is also necessary to explanation, herein, such as first and second or the like relational terms be used merely to by
One entity or operation make a distinction with another entity or operation, and not necessarily require or imply these entities or operation
Between there is any this actual relation or order.And, term " including ", "comprising" or its any other variant meaning
Covering including for nonexcludability, so that process, method, article or equipment including a series of key elements not only include that
A little key elements, but also other key elements including being not expressly set out, or also include for this process, method, article or
The intrinsic key element of equipment.In the absence of more restrictions, the key element limited by sentence "including a ...", does not arrange
Except also there is other identical element in the process including the key element, method, article or equipment.
Each embodiment is described by the way of progressive in this specification, and what each embodiment was stressed is and other
The difference of embodiment, between each embodiment identical similar portion mutually referring to.
The foregoing description of the disclosed embodiments, enables professional and technical personnel in the field to realize or uses the application.
Various modifications to these embodiments will be apparent for those skilled in the art, as defined herein
General Principle can in other embodiments be realized in the case where spirit herein or scope is not departed from.Therefore, the application
The embodiments shown herein is not intended to be limited to, and is to fit to and principles disclosed herein and features of novelty phase one
The scope most wide for causing.
Claims (10)
1. a kind of clocking method, it is characterised in that including:
It is determined that reach setting timing start condition when, obtain system timer timer time, as the first timer time;
When it is determined that reaching setting timing termination condition, the timer time of the system timer is obtained, during as the second timing
Carve;
It is determined that since reach setting timing the condition moment to reach setting the timing termination condition moment during, the system
The replacement number of times of timer;
Calculate the difference that second timer time subtracts first timer time, and replacement number of times and the system
Timer time-count cycle value product, and by the difference and the product and value be defined as timing result.
2. method according to claim 1, it is characterised in that the setting timing starts condition and starts including target service
Start, the setting timing termination condition includes the target service end of run, wherein the target service is the need for determining
Run the business of timing statistics.
3. method according to claim 2, it is characterised in that the maximum operation duration of the target service is no more than described
Value time-count cycle of system timer;
It is described determine from reach setting timing the condition moment to reach set the timing termination condition moment during, it is described
The replacement number of times of system timer, including:
Whether second timer time is judged no more than first timer time, if, it is determined that the system timer
It is 1 to reset number of times, otherwise, it determines it is 0 that the system timer resets number of times.
4. method according to claim 1, it is characterised in that the condition moment is extremely since reach setting timing for the determination
During reaching the setting timing termination condition moment, the replacement number of times of the system timer, including:
The monitored results that monitoring thread resets number of times to the system timer are obtained, the monitored results include the monitoring line
Journey since reach setting timing the condition moment to reach setting the timing termination condition moment during, what is monitored is
The number of times for being set to 0 is thought highly of during statistics;
The replacement number of times of the system timer is determined according to the monitored results.
5. the method according to claim any one of 1-4, it is characterised in that the system timer is Windows systems
Timer;
It is described it is determined that reach setting timing start condition when, obtain system timer timer time, during as the first timing
Carve, including:
It is determined that reach setting timing start condition when, call GetTickCount functions obtain the first timer time;
It is described to obtain the timer time of the system timer when it is determined that reaching setting timing termination condition, as the second meter
When the moment, including:
When it is determined that reaching setting timing termination condition, GetTickCount functions are called to obtain the second timer time again.
6. a kind of time set, it is characterised in that including:
First timer time acquiring unit, for it is determined that reach setting timing start condition when, obtain system timer meter
When the moment, as the first timer time;
Second timer time acquiring unit, for when it is determined that reaching setting timing termination condition, obtaining the system timer
Timer time, as the second timer time;
Reset number of times determining unit, for determine from reach setting timing the condition moment to reach set timing termination condition
During moment, the replacement number of times of the system timer;
Timing result determining unit, the difference of first timer time is subtracted for calculating second timer time, and
It is described reset number of times and the system timer time-count cycle value product, and by the difference and the product and be worth really
It is set to timing result.
7. device according to claim 6, it is characterised in that the setting timing starts condition and starts including target service
Start, the setting timing termination condition includes the target service end of run, wherein the target service is the need for determining
Run the business of timing statistics.
8. device according to claim 7, it is characterised in that the maximum operation duration of the target service is no more than described
Value time-count cycle of system timer;
The replacement number of times determining unit includes:
Whether first resets number of times determination subelement, during for judging second timer time no more than first timing
Carve, if, it is determined that it is 1 that the system timer resets number of times, otherwise, it determines it is 0 that the system timer resets number of times.
9. device according to claim 6, it is characterised in that the replacement number of times determining unit includes:
Second resets number of times determination subelement, resets the monitoring knot of number of times to the system timer for obtaining monitoring thread
Really, the monitored results include that the monitoring thread terminates since the condition moment reaching setting timing to setting timing is reached
During the condition moment, the system timer for being monitored resets to 0 number of times;
3rd resets number of times determination subelement, the replacement number of times for determining the system timer according to the monitored results.
10. the device according to claim any one of 6-9, it is characterised in that the system timer is Windows systems
Timer;
The first timer time acquiring unit includes:
First function call unit, for it is determined that reach setting timing start condition when, call GetTickCount functions to obtain
Take the first timer time;
The second timer time acquiring unit includes:
Second function call unit, for when it is determined that reaching setting timing termination condition, GetTickCount letters being called again
Number obtains the second timer time.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201710060613.8A CN106814789B (en) | 2017-01-25 | 2017-01-25 | Timing method and device |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201710060613.8A CN106814789B (en) | 2017-01-25 | 2017-01-25 | Timing method and device |
Publications (2)
Publication Number | Publication Date |
---|---|
CN106814789A true CN106814789A (en) | 2017-06-09 |
CN106814789B CN106814789B (en) | 2020-07-03 |
Family
ID=59111653
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN201710060613.8A Active CN106814789B (en) | 2017-01-25 | 2017-01-25 | Timing method and device |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN106814789B (en) |
Cited By (5)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN107606798A (en) * | 2017-08-28 | 2018-01-19 | 合肥美的暖通设备有限公司 | Networking timing proofreading method, system, computer, storage medium and electric equipment |
CN109218509A (en) * | 2017-07-04 | 2019-01-15 | 北京小米移动软件有限公司 | Breath screen display method, apparatus and computer readable storage medium |
CN109413697A (en) * | 2018-10-16 | 2019-03-01 | 中国联合网络通信集团有限公司 | A kind of configuration method and device of active timer |
CN110411474A (en) * | 2019-07-22 | 2019-11-05 | 杭州沃朴物联科技有限公司 | Step-recording method, equipment, medium, device, chicken board and management system for breeding |
CN110585716A (en) * | 2019-09-20 | 2019-12-20 | 腾讯科技(深圳)有限公司 | Virtual item control method, device, equipment and storage medium |
Citations (5)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
US5481507A (en) * | 1993-11-29 | 1996-01-02 | Mitsubishi Denki Kabushiki Kaisha | Electronic timekeeping device reduced adjustment data storage requirement |
GB2428113A (en) * | 2005-07-07 | 2007-01-17 | Visteon Global Tech Inc | Electronic timekeeping device using RDS signals |
CN102265237A (en) * | 2008-08-21 | 2011-11-30 | 克罗诺洛吉克有限公司 | Synchronisation and timing method and apparatus |
CN103257670A (en) * | 2012-02-21 | 2013-08-21 | 北京国微集成技术有限公司 | Embedded system and timing method thereof |
CN105745589A (en) * | 2013-10-14 | 2016-07-06 | 耐克创新有限合伙公司 | Adaptive timing configuration for athletic devices |
-
2017
- 2017-01-25 CN CN201710060613.8A patent/CN106814789B/en active Active
Patent Citations (5)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
US5481507A (en) * | 1993-11-29 | 1996-01-02 | Mitsubishi Denki Kabushiki Kaisha | Electronic timekeeping device reduced adjustment data storage requirement |
GB2428113A (en) * | 2005-07-07 | 2007-01-17 | Visteon Global Tech Inc | Electronic timekeeping device using RDS signals |
CN102265237A (en) * | 2008-08-21 | 2011-11-30 | 克罗诺洛吉克有限公司 | Synchronisation and timing method and apparatus |
CN103257670A (en) * | 2012-02-21 | 2013-08-21 | 北京国微集成技术有限公司 | Embedded system and timing method thereof |
CN105745589A (en) * | 2013-10-14 | 2016-07-06 | 耐克创新有限合伙公司 | Adaptive timing configuration for athletic devices |
Cited By (7)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN109218509A (en) * | 2017-07-04 | 2019-01-15 | 北京小米移动软件有限公司 | Breath screen display method, apparatus and computer readable storage medium |
US10698442B2 (en) | 2017-07-04 | 2020-06-30 | Beijing Xiaomi Mobile Software Co., Ltd. | Method and apparatus for always-on display applied in a display driver integrated circuit |
CN109218509B (en) * | 2017-07-04 | 2021-03-02 | 北京小米移动软件有限公司 | Information screen display method and device and computer readable storage medium |
CN107606798A (en) * | 2017-08-28 | 2018-01-19 | 合肥美的暖通设备有限公司 | Networking timing proofreading method, system, computer, storage medium and electric equipment |
CN109413697A (en) * | 2018-10-16 | 2019-03-01 | 中国联合网络通信集团有限公司 | A kind of configuration method and device of active timer |
CN110411474A (en) * | 2019-07-22 | 2019-11-05 | 杭州沃朴物联科技有限公司 | Step-recording method, equipment, medium, device, chicken board and management system for breeding |
CN110585716A (en) * | 2019-09-20 | 2019-12-20 | 腾讯科技(深圳)有限公司 | Virtual item control method, device, equipment and storage medium |
Also Published As
Publication number | Publication date |
---|---|
CN106814789B (en) | 2020-07-03 |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
CN106814789A (en) | A kind of clocking method and device | |
KR100613201B1 (en) | Measuring method for cpu usage | |
JP4650146B2 (en) | Printing apparatus and printing program | |
GB2429076A (en) | Time accumulator | |
CN106095609B (en) | Walking data check, modification method and system | |
CN103457741A (en) | Working method of dynamic token | |
CN111338425B (en) | Method and system for realizing countdown of wireless low-power-consumption equipment | |
CN113406992B (en) | System clock control method, processing device and readable storage medium | |
CN108363529A (en) | The determination method and device of the front stage operation time of Application Program Interface | |
CN109800146B (en) | Application program start time testing method and device, computer equipment and storage medium | |
CN114003498A (en) | Software anomaly detection method and device and electronic equipment | |
CN107423206A (en) | A kind of method and device for weighing the system management interrupt time | |
CN111414295A (en) | CPU occupancy rate statistical method, device, equipment and medium | |
KR100653545B1 (en) | Method of sensing time modification of internal time by a computer program | |
CN117784883A (en) | Optimization method and device for driving HRT timer and electronic equipment | |
JP2000074962A (en) | Cycle-measuring device and method therefor, and storage medium | |
CN112769961B (en) | Node processing method and device of network system | |
JP2604562B2 (en) | Pulse interval measuring device | |
JPH05143480A (en) | Monitor circuit for communication equipment | |
CN109901967B (en) | Storage pool residual capacity available time estimation method, electronic device and storage medium | |
CN112463125B (en) | Timing method and equipment of virtual timer | |
JPH09114541A (en) | Interruption generation time confirming circuit and processor | |
CN111105302B (en) | Data processing method, device, server and storage medium | |
JPH04144322A (en) | Monitoring system in communication error detection | |
CN115729313A (en) | Method and device for calibrating real-time clock and electronic equipment |
Legal Events
Date | Code | Title | Description |
---|---|---|---|
PB01 | Publication | ||
PB01 | Publication | ||
SE01 | Entry into force of request for substantive examination | ||
SE01 | Entry into force of request for substantive examination | ||
GR01 | Patent grant | ||
GR01 | Patent grant |