CN110391861B - Method, device, equipment and storage medium for correcting timer - Google Patents

Method, device, equipment and storage medium for correcting timer Download PDF

Info

Publication number
CN110391861B
CN110391861B CN201810354435.4A CN201810354435A CN110391861B CN 110391861 B CN110391861 B CN 110391861B CN 201810354435 A CN201810354435 A CN 201810354435A CN 110391861 B CN110391861 B CN 110391861B
Authority
CN
China
Prior art keywords
time
timer
current
server
value
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.)
Active
Application number
CN201810354435.4A
Other languages
Chinese (zh)
Other versions
CN110391861A (en
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.)
Beijing Jingdong Century Trading Co Ltd
Beijing Jingdong Shangke Information Technology Co Ltd
Original Assignee
Beijing Jingdong Century Trading Co Ltd
Beijing Jingdong Shangke Information Technology 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 Beijing Jingdong Century Trading Co Ltd, Beijing Jingdong Shangke Information Technology Co Ltd filed Critical Beijing Jingdong Century Trading Co Ltd
Priority to CN201810354435.4A priority Critical patent/CN110391861B/en
Publication of CN110391861A publication Critical patent/CN110391861A/en
Application granted granted Critical
Publication of CN110391861B publication Critical patent/CN110391861B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Classifications

    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04JMULTIPLEX COMMUNICATION
    • H04J3/00Time-division multiplex systems
    • H04J3/02Details
    • H04J3/06Synchronising arrangements
    • H04J3/0635Clock or time synchronisation in a network
    • H04J3/0638Clock or time synchronisation among nodes; Internode synchronisation
    • H04J3/0658Clock or time synchronisation among packet nodes
    • H04J3/0661Clock or time synchronisation among packet nodes using timestamps

Abstract

The invention discloses a method and a device for correcting a timer, and relates to the technical field of computers. One embodiment of the method comprises the following steps: receiving a waiting time duration issued by an application server and acquiring an initial timestamp of a time server; calling a timer, and starting to count according to the duration to be counted; and acquiring the current time stamp of the time server every preset correction period, determining the time deviation of the timer according to the difference value between the current time stamp and the initial time stamp of the time server, and compensating the time deviation to the current timing value of the timer. This embodiment can solve the problem that the time-recorder timing precision is low.

Description

Method, device, equipment and storage medium for correcting timer
Technical Field
The present invention relates to the field of computer technologies, and in particular, to a method and an apparatus for correcting a timer.
Background
In the internet field, timers are a very popular technology commonly used in web pages or application programs (APP) to count down on showing related activities. If the timing time is short and the timer is not too many, there is no great influence on the accuracy of the timer. However, if in a complex timing scenario, there are more than ten items involved in the promotion, the timer will typically begin counting from more than 10 hours, or even longer. When the timers for so many items are timed simultaneously, if the machine load on which the system browser is located is large, the accuracy of the timers can be greatly affected.
In the process of implementing the present invention, the inventor finds that at least the following problems exist in the prior art: if the pressure load of the system is large or abnormal conditions occur, the timer is delayed, and if the time is long, serious errors are accumulated, so that the user experience is seriously degraded.
Disclosure of Invention
In view of the above, the embodiments of the present invention provide a method and an apparatus for correcting a timer, which can solve the problem of low timing accuracy of the timer.
To achieve the above object, according to an aspect of an embodiment of the present invention, there is provided a method of correcting a timer, including:
receiving a waiting time duration issued by an application server and acquiring an initial timestamp of a time server;
calling a timer, and starting to count according to the duration to be counted;
and acquiring the current time stamp of the time server every preset correction period, determining the time deviation of the timer according to the difference value between the current time stamp and the initial time stamp of the time server, and compensating the time deviation to the current timing value of the timer.
Optionally, acquiring the current timestamp of the time server, determining the time deviation of the timer according to the difference between the current timestamp of the time server and the initial timestamp, including:
acquiring a current time stamp of a time server to determine a difference value between the current time stamp and an initial time stamp of the time server;
acquiring a current timing value of a timer to determine a difference value between the duration to be timed of the timer and the current timing value;
and determining the time deviation of the timer according to the difference value between the current time stamp and the initial time stamp of the time server and the difference value between the duration to be counted and the current time value of the timer.
Optionally, obtaining the current timing value of the timer to determine a difference between the duration to be timed of the timer and the current timing value includes:
determining a timer with the maximum time length to be counted according to the time lengths to be counted of all the timers;
and acquiring the current timing value of the timer with the largest time length to be timed so as to determine the difference value between the time length to be timed of the timer with the largest time length to be timed and the current timing value.
Optionally, the current time stamp of the time server is obtained at intervals of a preset correction period, the time deviation of the timer is determined according to the difference value between the current time stamp and the initial time stamp of the time server, and the time deviation is compensated to the current timing value of the timer, which comprises:
judging whether the maximum time length to be counted is greater than the preset correction period, if so, determining the time deviation of the timer according to the difference value between the current time stamp and the initial time stamp of the time server every preset correction period, and compensating the time deviation to the current time value of the timer; if not, determining the time deviation of the timer according to the difference value between the local current time stamp and the initial time stamp of the time server, and compensating the time deviation to the current time value of the timer.
Optionally, compensating the time offset to a current timing value of a timer includes:
judging whether the time deviation is larger than or equal to a preset time deviation, if so, respectively adding the time deviation to the current timing values of all timers as new current timing values, and continuing to start timing; if not, continuing to start timing according to the current timing value of the timer.
In addition, according to another aspect of the embodiment of the present invention, there is provided an apparatus for correcting a timer, including:
the receiving module is used for receiving the to-be-timed duration issued by the application server and acquiring an initial timestamp of the time server;
the timing module is used for calling a timer and starting timing according to the duration to be timed;
the correction module is used for acquiring the current time stamp of the time server every other preset correction period, determining the time deviation of the timer according to the difference value between the current time stamp of the time server and the initial time stamp, and compensating the time deviation to the current timing value of the timer.
Optionally, acquiring the current timestamp of the time server, determining the time deviation of the timer according to the difference between the current timestamp of the time server and the initial timestamp, including:
acquiring a current time stamp of a time server to determine a difference value between the current time stamp and an initial time stamp of the time server;
acquiring a current timing value of a timer to determine a difference value between the duration to be timed of the timer and the current timing value;
and determining the time deviation of the timer according to the difference value between the current time stamp and the initial time stamp of the time server and the difference value between the duration to be counted and the current time value of the timer.
Optionally, obtaining the current timing value of the timer to determine a difference between the duration to be timed of the timer and the current timing value includes:
determining a timer with the maximum time length to be counted according to the time lengths to be counted of all the timers;
and acquiring the current timing value of the timer with the largest time length to be timed so as to determine the difference value between the time length to be timed of the timer with the largest time length to be timed and the current timing value.
Optionally, the correction module is configured to:
judging whether the maximum time length to be counted is greater than the preset correction period, if so, determining the time deviation of the timer according to the difference value between the current time stamp and the initial time stamp of the time server every preset correction period, and compensating the time deviation to the current time value of the timer; if not, determining the time deviation of the timer according to the difference value between the local current time stamp and the initial time stamp of the time server, and compensating the time deviation to the current time value of the timer.
Optionally, compensating the time offset to a current timing value of a timer includes:
judging whether the time deviation is larger than or equal to a preset time deviation, if so, respectively adding the time deviation to the current timing values of all timers as new current timing values, and continuing to start timing; if not, continuing to start timing according to the current timing value of the timer.
According to another aspect of an embodiment of the present invention, there is also provided an electronic device including:
one or more processors;
storage means for storing one or more programs,
the one or more programs, when executed by the one or more processors, cause the one or more processors to implement the methods of any of the embodiments described above.
According to another aspect of an embodiment of the present invention, there is also provided a computer readable medium having stored thereon a computer program which, when executed by a processor, implements the method according to any of the embodiments described above.
One embodiment of the above invention has the following advantages or benefits: because the technical means of determining the time deviation of the timer according to the difference value between the current time stamp and the initial time stamp of the time server and compensating the time deviation to the current timing value of the timer is adopted, the technical problem of low timing accuracy of the timer is solved, the time difference is reduced through periodical time synchronization with the time server, and the timing accuracy is improved. Especially, under the condition that a plurality of timers are large in timing duration, the beneficial effects of the embodiment of the invention are more remarkable, and the timing accuracy of each timer for a long time can be ensured. Therefore, the method for correcting the timer mainly uses the timer technology and the time synchronization technology to regularly correct the time of the timer, so that no matter how long the time is, the system load pressure is large, and no large time error is generated.
Further effects of the above-described non-conventional alternatives are described below in connection with the embodiments.
Drawings
The drawings are included to provide a better understanding of the invention and are not to be construed as unduly limiting the invention. Wherein:
FIG. 1 is a diagram of an exemplary system architecture for independent counting of a plurality of timers in the prior art;
FIG. 2 is a schematic diagram of the main flow of a method of correcting a timer according to an embodiment of the present invention;
FIG. 3 is an exemplary system architecture diagram for independent timing of multiple timers according to an embodiment of the present invention;
FIG. 4 is a schematic diagram of the main flow of a method of correcting a timer according to one referenceable embodiment of the invention;
FIG. 5 is a schematic diagram of the main modules of an apparatus for correcting a timer according to an embodiment of the present invention;
FIG. 6 is an exemplary system architecture diagram in which embodiments of the present invention may be applied;
fig. 7 is a schematic diagram of a computer system suitable for use in implementing an embodiment of the invention.
Detailed Description
Exemplary embodiments of the present invention will now be described with reference to the accompanying drawings, in which various details of the embodiments of the present invention are included to facilitate understanding, and are to be considered merely exemplary. Accordingly, those of ordinary skill in the art will recognize that various changes and modifications of the embodiments described herein can be made without departing from the scope and spirit of the invention. Also, descriptions of well-known functions and constructions are omitted in the following description for clarity and conciseness.
The technical scheme in the prior art mainly comprises a plurality of independent timers, each timer is used for independently counting, but the method is only suitable for a simple scene, and if the timers are used under a large load, a large difference can be generated when the timers count simultaneously. As shown in fig. 1, the application server issues time data of each timer, and each timer of the client counts down independently, which is simple and easy to implement, but has a problem that each timer counts independently and updates its own time independently. The individual timers themselves will have a slight time gap, which will be amplified if the system load is large, and which will result in an increasingly larger gap in the timing of the individual timers if the timing time is long.
The method for correcting the timer mainly uses the timer technology and the time synchronization technology to regularly correct the time of the timer, so that no matter how long the time is, the system load pressure is, and no longer generates great time errors.
Fig. 1 is a method of correcting a timer according to an embodiment of the present invention. As an embodiment of the present invention, as shown in fig. 1, the method for correcting a timer may include:
step 101, receiving a waiting time duration issued by an application server and an initial timestamp of an acquisition time server.
In this step, the client receives the duration to be timed issued by the application server, and obtains an initial timestamp of the time server, that is, a current timestamp of the time server when the timestamp was obtained.
FIG. 3 is an exemplary system architecture diagram for independent timing of multiple timers according to an embodiment of the present invention. As shown in fig. 3, the application Server (Application Server) issues the duration to be counted of all the timers, and the client receives the duration to be counted of all the timers, and at the same time, the client pulls the current timestamp of the time Server (Ntp Server) to use the current timestamp when pulling as the initial timestamp (startTimestamp) of the time Server.
It should be noted that the timer may show the countdown duration through the view layer, the number of the counters is not limited, there may be a plurality of timers for each client, and the duration to be counted may be different for each timer.
Optionally, the application server and the time server perform Socket (Socket) communication in real time to ensure time synchronization between the application server and the time server.
And 102, calling a timer, and starting timing according to the duration to be timed.
After receiving the duration to be timed issued by the application server, the client calls the local timer to start timing according to the respective corresponding duration to be timed. It should be noted that, since the time length to be counted is different for each timer, there will be a timer with the largest time length and a timer with the smallest time length.
Step 103, obtaining the current time stamp of the time server every preset correction period, determining the time deviation of the timer according to the difference value between the current time stamp and the initial time stamp of the time server, and compensating the time deviation to the current timing value of the timer.
Since the individual timers themselves have a slight time gap, if the system load is large, the gap is amplified, and if the time duration is large, the timing of the individual timers has an increasing gap. Therefore, the embodiment of the invention periodically calculates the time deviation of the timer and compensates the time deviation to the current time value of the timer, thereby reducing the time deviation and improving the timing accuracy of the timer.
As yet another embodiment of the present invention, step 103 includes: judging whether the maximum time length to be counted is greater than the preset correction period, if so, determining the time deviation of the timer according to the difference value between the current time stamp and the initial time stamp of the time server every preset correction period, and compensating the time deviation to the current time value of the timer; if not, determining the time deviation of the timer according to the difference value between the local current time stamp and the initial time stamp of the time server, and compensating the time deviation to the current time value of the timer.
Specifically, according to the time duration of all the timers, the timer with the largest time duration to be counted in all the timers is determined, and the time synchronization period is set to be N minutes (for example, 20 minutes, 30 minutes, 45 minutes or 60 minutes, etc.), and the time synchronization period can be set as appropriate. If the maximum time waiting duration is less than or equal to N minutes, the current time stamp of the time server is not acquired, but the local current time stamp is directly acquired, then the time deviation of the timer is determined according to the difference value between the local current time stamp and the initial time stamp of the time server, and the time deviation is compensated to the current time value of the timer. And if the maximum time waiting duration is greater than N minutes, acquiring the current time stamp of the time server, determining the time deviation of the timer according to the difference value between the current time stamp and the initial time stamp of the time server, and compensating the time deviation to the current time value of the timer.
As still another embodiment of the present invention, obtaining a current timestamp of a time server, determining a time offset of the timer according to a difference between the current timestamp of the time server and an initial timestamp, includes: acquiring a current time stamp of a time server to determine a difference value between the current time stamp and an initial time stamp of the time server; acquiring a current timing value of a timer to determine a difference value between the duration to be timed of the timer and the current timing value; and determining the time deviation of the timer according to the difference value between the current time stamp and the initial time stamp of the time server and the difference value between the duration to be counted and the current time value of the timer. It is noted that the current timestamp of the time server and the current timer value of the timer may be acquired simultaneously to reduce the time offset as much as possible.
Optionally, since the duration to be counted of each timer is different, the embodiment of the invention determines the time deviation by the timer with the largest duration to be counted, so as to compensate the time deviation to the current time values of all timers. Specifically, obtaining a current timing value of the timer to determine a difference between a duration to be timed of the timer and the current timing value, including: determining a timer with the maximum time length to be counted according to the time lengths to be counted of all the timers; and acquiring the current timing value of the timer with the largest time length to be timed so as to determine the difference value between the time length to be timed of the timer with the largest time length to be timed and the current timing value.
The following is a detailed description taking fig. 3 as an example:
the time synchronization timer performs time synchronization with the time server in a period after N minutes, acquires a current time stamp (circumTimestamp) of the time server, acquires a current VALUE (VALUE) of a timer with the largest duration to be timed by the timer, and performs the following calculation according to the current time stamp of the time server acquired by the time synchronization timer:
the current interval timestamp is time= (circumsetimestamp-startTimestamp) seconds;
second= (MAX-VALUE) seconds when the timer with the maximum time length is counted;
time offset between the timer with the largest duration to be counted and the time server=time-second;
the value of offset is generally positive because the timer is typically inaccurate due to various factors such as system pressure, etc. As yet another embodiment of the present invention, if the offset is greater than or equal to 1 second, the timing operation continues to begin after all timer values have been added to the offset value. If offset <1 second, no calibration is done and each timer should continue to count.
And step 103, performing time correction once in each preset correction period until the timer with the maximum time length to be counted finishes counting, and stopping counting by the time counting timer and the time synchronization timer at the moment. Thus, the more the period of correction, the more the number of corrections. Therefore, the larger the maximum timing time length is, the more obvious the advantages of the embodiment of the invention are, so that the system with larger system load has good correction effect.
The time synchronization timer is mainly used for pulling the latest time stamp from the time server, and if the current client has time deviation, the time stamp of the time server can also be used for correction. The timer is used for uniformly managing the timing work of all the timers and uniformly updating the duration data to be timed of all the timers. Thus, in another embodiment of the present invention, the time synchronization timer is time-synchronized with the time server to time-calibrate the time stamps, and the timer calculates a time offset after each time interval (i.e., a preset update period) to update the duration of the timer to be timed.
Alternatively, the timing management and updating of all timers are implemented by one timer, so that resources are less occupied. Because the number of timers is small, factors affecting the time accuracy are reduced, and the time accuracy is remarkably improved.
Further, to ensure the accuracy of the timer, the timer runs in a separate thread, preventing the accuracy from being affected by the system pressure. Alternatively, the time synchronization timer and the timing timer each run in a separate thread.
The scene that fire and explosion activities are counted down and are robbed is just to 0 on the network is frequently generated, and in fact, the client timing is different from the server timing, and the synchronization is caused. The method provided by the embodiment of the invention can reduce the time difference and improve the user experience.
According to the various embodiments described above, it can be seen that the present invention solves the problem of low timing accuracy of the timer by determining the time deviation of the timer according to the difference between the current time stamp and the initial time stamp of the time server, and compensating the time deviation to the current timing value of the timer. That is, in the prior art, the application server issues time data of each timer, and each timer of the client independently counts down, which has the problem that each timer independently counts up and independently updates own time, if the system load is large, the gap is amplified, and if the counting time is long, the gap exists between the counts of each timer. The invention reduces the time difference through the periodical time synchronization with the time server, and improves the timing accuracy. Especially, under the condition that a plurality of timers are large in timing duration, the beneficial effects of the embodiment of the invention are more remarkable, and the timing accuracy of each timer for a long time can be ensured. Therefore, the method for correcting the timer mainly uses the timer technology and the time synchronization technology to regularly correct the time of the timer, so that no matter how long the time is, the system load pressure is large, and no large time error is generated.
Fig. 4 is a schematic diagram of the main flow of a method of correcting a timer according to one referenceable embodiment of the invention. As still another embodiment of the present invention, the method for correcting a timer may specifically include:
step 401, receiving a to-be-timed duration issued by an application server and an initial timestamp of an acquisition time server;
step 402, calling all timers to start timing according to the corresponding time duration to be timed;
step 403, judging whether the maximum time duration to be counted is greater than the preset correction period, if yes, executing step 405, and if no, executing step 404;
step 404, determining a time deviation of the timer according to a difference between the local current time stamp and the initial time stamp of the time server and a difference between a to-be-counted time length of the timer with the largest to-be-counted time length and the current counting value;
step 405, determining a time deviation of a timer according to a difference between a current time stamp and an initial time stamp of a time server and a difference between a to-be-counted time length of the timer with the maximum to-be-counted time length and a current counting value;
step 406, judging whether the time deviation is greater than or equal to the preset time deviation, if so, executing step 407, otherwise, executing step 408;
step 407, compensating the time deviation to the current timing values of all timers, and continuing to start timing;
step 408, the timer is started continuously according to the current timing value of the timer.
Steps 405-408 are repeated every preset correction period until the timer with the maximum duration to be counted finishes counting.
According to the various embodiments described above, it can be seen that the present invention solves the problem of low timing accuracy of the timer by determining the time deviation of the timer according to the difference between the current time stamp and the initial time stamp of the time server, and compensating the time deviation to the current timing value of the timer. That is, in the prior art, the application server issues time data of each timer, and each timer of the client independently counts down, which has the problem that each timer independently counts up and independently updates own time, if the system load is large, the gap is amplified, and if the counting time is long, the gap exists between the counts of each timer. The invention reduces the time difference through the periodical time synchronization with the time server, and improves the timing accuracy. Especially, under the condition that a plurality of timers are large in timing duration, the beneficial effects of the embodiment of the invention are more remarkable, and the timing accuracy of each timer for a long time can be ensured. Therefore, the method for correcting the timer mainly uses the timer technology and the time synchronization technology to regularly correct the time of the timer, so that no matter how long the time is, the system load pressure is large, and no large time error is generated.
In addition, the specific implementation of the method for correcting a timer according to the embodiment of the present invention is described in detail in the method for correcting a timer, and thus the description thereof will not be repeated here.
Fig. 5 is a schematic diagram of main modules of an apparatus for correcting a timer according to an embodiment of the present invention. As shown in fig. 5, the apparatus 500 for correcting a timer includes a receiving module 501, a timing module 502, and a correcting module 503. The receiving module 501 receives a duration to be timed issued by an application server and an initial timestamp of an acquisition time server; the timing module 502 calls a timer and starts timing according to the duration to be timed; the correction module 503 obtains the current timestamp of the time server every preset correction period, determines the time deviation of the timer according to the difference between the current timestamp of the time server and the initial timestamp, and compensates the time deviation to the current timing value of the timer.
Optionally, acquiring the current timestamp of the time server, determining the time deviation of the timer according to the difference between the current timestamp of the time server and the initial timestamp, including: acquiring a current time stamp of a time server to determine a difference value between the current time stamp and an initial time stamp of the time server; acquiring a current timing value of a timer to determine a difference value between the duration to be timed of the timer and the current timing value; and determining the time deviation of the timer according to the difference value between the current time stamp and the initial time stamp of the time server and the difference value between the duration to be counted and the current time value of the timer.
Optionally, obtaining the current timing value of the timer to determine a difference between the duration to be timed of the timer and the current timing value includes: determining a timer with the maximum time length to be counted according to the time lengths to be counted of all the timers; and acquiring the current timing value of the timer with the largest time length to be timed so as to determine the difference value between the time length to be timed of the timer with the largest time length to be timed and the current timing value.
Optionally, the correction module 503 determines whether the maximum to-be-counted duration is greater than the preset correction period, if so, determining a time deviation of the timer according to a difference value between a current timestamp of the time server and an initial timestamp every preset correction period, and compensating the time deviation to the current counted value of the timer; if not, determining the time deviation of the timer according to the difference value between the local current time stamp and the initial time stamp of the time server, and compensating the time deviation to the current time value of the timer.
Optionally, compensating the time offset to a current timing value of a timer includes: judging whether the time deviation is larger than or equal to a preset time deviation, if so, respectively adding the time deviation to the current timing values of all timers as new current timing values, and continuing to start timing; if not, continuing to start timing according to the current timing value of the timer.
According to the various embodiments described above, it can be seen that the present invention solves the problem of low timing accuracy of the timer by determining the time deviation of the timer according to the difference between the current time stamp and the initial time stamp of the time server, and compensating the time deviation to the current timing value of the timer. That is, in the prior art, the application server issues time data of each timer, and each timer of the client independently counts down, which has the problem that each timer independently counts up and independently updates own time, if the system load is large, the gap is amplified, and if the counting time is long, the gap exists between the counts of each timer. The invention reduces the time difference through the periodical time synchronization with the time server, and improves the timing accuracy. Especially, under the condition that a plurality of timers are large in timing duration, the beneficial effects of the embodiment of the invention are more remarkable, and the timing accuracy of each timer for a long time can be ensured. Therefore, the device for correcting the timer mainly uses the timer technology and the time synchronization technology to regularly correct the time of the timer, so that no matter how long the time is, the system load pressure is large, and no large time error is generated.
The specific implementation of the device for correcting a timer according to the present invention is described in detail in the method for correcting a timer, and thus, the description thereof will not be repeated here.
Fig. 6 illustrates an exemplary system architecture 600 of a method of correcting a timer or an apparatus of correcting a timer to which embodiments of the present invention may be applied.
As shown in fig. 6, the system architecture 600 may include terminal devices 601, 602, 603, a network 604, and a server 605. The network 604 is used as a medium to provide communication links between the terminal devices 601, 602, 603 and the server 605. The network 604 may include various connection types, such as wired, wireless communication links, or fiber optic cables, among others.
A user may interact with the server 605 via the network 604 using the terminal devices 601, 602, 603 to receive or send messages, etc. Various communication client applications such as shopping class applications, web browser applications, search class applications, instant messaging tools, mailbox clients, social platform software, etc. (by way of example only) may be installed on the terminal devices 601, 602, 603.
The terminal devices 601, 602, 603 may be various electronic devices having a display screen and supporting web browsing, including but not limited to smartphones, tablets, laptop and desktop computers, and the like.
The server 605 may be a server providing various services, such as a background management server (by way of example only) providing support for shopping-type websites browsed by users using terminal devices 601, 602, 603. The background management server may analyze and process the received data such as the product information query request, and feedback the processing result (e.g., the target push information, the product information—only an example) to the terminal device.
It should be noted that, the method for correcting the timer provided in the embodiment of the present invention is generally performed on the terminal devices 601, 602, 603 in the public place, and may also be performed by the server 605, and accordingly, the device for correcting the timer is generally disposed on the terminal devices 601, 602, 603 in the public place, and may also be disposed in the server 605.
It should be understood that the number of terminal devices, networks and servers in fig. 6 is merely illustrative. There may be any number of terminal devices, networks, and servers, as desired for implementation.
Referring now to FIG. 7, there is illustrated a schematic diagram of a computer system 700 suitable for use in implementing an embodiment of the present invention. The terminal device shown in fig. 7 is only an example, and should not impose any limitation on the functions and the scope of use of the embodiment of the present invention.
As shown in fig. 7, the computer system 700 includes a Central Processing Unit (CPU) 701, which can perform various appropriate actions and processes according to a program stored in a Read Only Memory (ROM) 702 or a program loaded from a storage section 708 into a Random Access Memory (RAM) 703. In the RAM 703, various programs and data required for the operation of the system 700 are also stored. The CPU 701, ROM 702, and RAM 703 are connected to each other through a bus 704. An input/output (I/O) interface 705 is also connected to bus 704.
The following components are connected to the I/O interface 705: an input section 706 including a keyboard, a mouse, and the like; an output portion 707 including a Cathode Ray Tube (CRT), a Liquid Crystal Display (LCD), and the like, a speaker, and the like; a storage section 708 including a hard disk or the like; and a communication section 709 including a network interface card such as a LAN card, a modem, or the like. The communication section 709 performs communication processing via a network such as the internet. The drive 710 is also connected to the I/O interface 705 as needed. A removable medium 711 such as a magnetic disk, an optical disk, a magneto-optical disk, a semiconductor memory, or the like is mounted on the drive 710 as necessary, so that a computer program read therefrom is mounted into the storage section 708 as necessary.
In particular, according to embodiments of the present disclosure, the processes described above with reference to flowcharts may be implemented as computer software programs. For example, embodiments of the present disclosure include a computer program product comprising a computer program embodied on a computer readable medium, the computer program comprising program code for performing the method shown in the flow chart. In such an embodiment, the computer program may be downloaded and installed from a network via the communication portion 709, and/or installed from the removable medium 711. The above-described functions defined in the system of the present invention are performed when the computer program is executed by a Central Processing Unit (CPU) 701.
The computer readable medium shown in the present invention may be a computer readable signal medium or a computer readable storage medium, or any combination of the two. The computer readable storage medium can be, for example, but not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or a combination of any of the foregoing. More specific examples of the computer-readable storage medium may include, but are not limited to: an electrical connection having one or more wires, a portable computer diskette, 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. In the context of this document, a computer 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. In the present invention, however, the computer-readable signal medium may include a data signal propagated in baseband or as part of a carrier wave, with the computer-readable program code embodied therein. Such a propagated data signal may take any of a variety of forms, including, but not limited to, electro-magnetic, optical, or any suitable combination of the foregoing. A computer readable signal medium may also be any computer readable medium that is not a computer 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 computer readable medium may be transmitted using any appropriate medium, including but not limited to: wireless, wire, fiber optic cable, RF, etc., or any suitable combination of the foregoing.
The flowcharts and block diagrams in the figures illustrate the architecture, functionality, and operation of possible implementations of systems, methods and computer program products according to various embodiments of the present invention. In this regard, each block in the flowchart or block diagrams may represent a module, segment, or portion of code, which comprises one or more executable instructions for implementing the specified logical function(s). It should also be noted that, in some alternative implementations, the functions noted in the block may occur out of the order noted in the figures. For example, two blocks shown in succession may, in fact, be executed substantially concurrently, or the blocks may sometimes be executed in the reverse order, depending upon the functionality involved. It will also be noted that each block of the block diagrams or flowchart illustration, and combinations of blocks in the block diagrams or flowchart illustration, can be implemented by special purpose hardware-based systems which perform the specified functions or acts, or combinations of special purpose hardware and computer instructions.
The modules involved in the embodiments of the present invention may be implemented in software or in hardware. The described modules may also be provided in a processor, for example, as: a processor includes a receiving module, a timing module, and a correction module, where the names of the modules do not constitute a limitation of the module itself in some cases.
As another aspect, the present invention also provides a computer-readable medium that may be contained in the apparatus described in the above embodiments; or may be present alone without being fitted into the device. The computer readable medium carries one or more programs which, when executed by a device, cause the device to include: receiving a waiting time duration issued by an application server and acquiring an initial timestamp of a time server; calling a timer, and starting to count according to the duration to be counted; and acquiring the current time stamp of the time server every preset correction period, determining the time deviation of the timer according to the difference value between the current time stamp and the initial time stamp of the time server, and compensating the time deviation to the current timing value of the timer.
According to the technical scheme of the embodiment of the invention, the technical means of determining the time deviation of the timer according to the difference value between the current time stamp and the initial time stamp of the time server and compensating the time deviation to the current time value of the timer is adopted, so that the technical problem of low time accuracy of the timer is solved, the time difference is reduced through periodical time synchronization with the time server, and the time accuracy is improved. Especially, under the condition that a plurality of timers are large in timing duration, the beneficial effects of the embodiment of the invention are more remarkable, and the timing accuracy of each timer for a long time can be ensured. Therefore, the method for correcting the timer mainly uses the timer technology and the time synchronization technology to regularly correct the time of the timer, so that no matter how long the time is, the system load pressure is large, and no large time error is generated.
The above embodiments do not limit the scope of the present invention. It will be apparent to those skilled in the art that various modifications, combinations, sub-combinations and alternatives can occur depending upon design requirements and other factors. Any modifications, equivalent substitutions and improvements made within the spirit and principles of the present invention should be included in the scope of the present invention.

Claims (8)

1. A method of calibrating a timer, comprising:
receiving a waiting time duration issued by an application server and acquiring an initial timestamp of a time server;
calling a timer, and starting to count according to the duration to be counted;
acquiring a current time stamp of a time server every preset correction period, determining the time deviation of the timer according to the difference value between the current time stamp and the initial time stamp of the time server, and compensating the time deviation to the current time value of the timer;
acquiring a current time stamp of a time server, determining a time deviation of the timer according to a difference value between the current time stamp and an initial time stamp of the time server, including:
acquiring a current time stamp of a time server to determine a difference value between the current time stamp and an initial time stamp of the time server;
determining a timer with the maximum time length to be counted according to the time lengths to be counted of all the timers;
acquiring a current timing value of the timer with the largest time length to be timed so as to determine a difference value between the time length to be timed of the timer with the largest time length to be timed and the current timing value;
and determining the time deviation of the timer according to the difference value between the current time stamp and the initial time stamp of the time server and the difference value between the duration to be counted and the current time value of the timer.
2. The method of claim 1, wherein the obtaining the current timestamp of the time server every a preset correction period, determining the time offset of the timer based on the difference between the current timestamp of the time server and the initial timestamp, and compensating the time offset to the current timing value of the timer, comprises:
judging whether the maximum time length to be counted is greater than the preset correction period, if so, determining the time deviation of the timer according to the difference value between the current time stamp and the initial time stamp of the time server every preset correction period, and compensating the time deviation to the current time value of the timer; if not, determining the time deviation of the timer according to the difference value between the local current time stamp and the initial time stamp of the time server, and compensating the time deviation to the current time value of the timer.
3. The method of claim 1, wherein compensating the time offset to a current timing value of a timer comprises:
judging whether the time deviation is larger than or equal to a preset time deviation, if so, respectively adding the time deviation to the current timing values of all timers as new current timing values, and continuing to start timing; if not, continuing to start timing according to the current timing value of the timer.
4. An apparatus for calibrating a timer, comprising:
the receiving module is used for receiving the to-be-timed duration issued by the application server and acquiring an initial timestamp of the time server;
the timing module is used for calling a timer and starting timing according to the duration to be timed;
the correction module is used for acquiring the current time stamp of the time server every other preset correction period, determining the time deviation of the timer according to the difference value between the current time stamp of the time server and the initial time stamp, and compensating the time deviation to the current timing value of the timer;
the correction module is also used for executing the following operations:
acquiring a current time stamp of a time server to determine a difference value between the current time stamp and an initial time stamp of the time server;
determining a timer with the maximum time length to be counted according to the time lengths to be counted of all the timers;
acquiring a current timing value of the timer with the largest time length to be timed so as to determine a difference value between the time length to be timed of the timer with the largest time length to be timed and the current timing value;
and determining the time deviation of the timer according to the difference value between the current time stamp and the initial time stamp of the time server and the difference value between the duration to be counted and the current time value of the timer.
5. The apparatus of claim 4, wherein the correction module is to:
judging whether the maximum time length to be counted is greater than the preset correction period, if so, determining the time deviation of the timer according to the difference value between the current time stamp and the initial time stamp of the time server every preset correction period, and compensating the time deviation to the current time value of the timer; if not, determining the time deviation of the timer according to the difference value between the local current time stamp and the initial time stamp of the time server, and compensating the time deviation to the current time value of the timer.
6. The apparatus of claim 4, wherein compensating the time offset to the current timing value of the timer comprises:
judging whether the time deviation is larger than or equal to a preset time deviation, if so, respectively adding the time deviation to the current timing values of all timers as new current timing values, and continuing to start timing; if not, continuing to start timing according to the current timing value of the timer.
7. An electronic device, comprising:
one or more processors;
storage means for storing one or more programs,
when executed by the one or more processors, causes the one or more processors to implement the method of any of claims 1-3.
8. A computer readable medium, on which a computer program is stored, characterized in that the program, when being executed by a processor, implements the method according to any of claims 1-3.
CN201810354435.4A 2018-04-19 2018-04-19 Method, device, equipment and storage medium for correcting timer Active CN110391861B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201810354435.4A CN110391861B (en) 2018-04-19 2018-04-19 Method, device, equipment and storage medium for correcting timer

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201810354435.4A CN110391861B (en) 2018-04-19 2018-04-19 Method, device, equipment and storage medium for correcting timer

Publications (2)

Publication Number Publication Date
CN110391861A CN110391861A (en) 2019-10-29
CN110391861B true CN110391861B (en) 2023-12-05

Family

ID=68283585

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201810354435.4A Active CN110391861B (en) 2018-04-19 2018-04-19 Method, device, equipment and storage medium for correcting timer

Country Status (1)

Country Link
CN (1) CN110391861B (en)

Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101546169A (en) * 2009-04-15 2009-09-30 北京航空航天大学 Method and device for calibrating time
CN103236896A (en) * 2013-04-07 2013-08-07 北京全路通信信号研究设计院有限公司 Clock adjusting method and clock adjusting system for vehicular control equipment
CN106788957A (en) * 2016-12-30 2017-05-31 广州华多网络科技有限公司 A kind of method and device of check timer time error
CN106993028A (en) * 2017-03-20 2017-07-28 山东浪潮商用系统有限公司 Network time acquisition methods, apparatus and system, computer-readable recording medium and storage control

Family Cites Families (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US9814007B2 (en) * 2015-09-25 2017-11-07 Intel Corporation Synchronizing time among two or more devices

Patent Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101546169A (en) * 2009-04-15 2009-09-30 北京航空航天大学 Method and device for calibrating time
CN103236896A (en) * 2013-04-07 2013-08-07 北京全路通信信号研究设计院有限公司 Clock adjusting method and clock adjusting system for vehicular control equipment
CN106788957A (en) * 2016-12-30 2017-05-31 广州华多网络科技有限公司 A kind of method and device of check timer time error
CN106993028A (en) * 2017-03-20 2017-07-28 山东浪潮商用系统有限公司 Network time acquisition methods, apparatus and system, computer-readable recording medium and storage control

Non-Patent Citations (1)

* Cited by examiner, † Cited by third party
Title
贾平平 ; 艾艳 ; 武鹏 ; 杨立志 ; 卫权岗 ; 任宏 ; 刘静 ; .基于NTP的网络对时系统设计与实现.气象与环境科学.2010,(04),第89-91页. *

Also Published As

Publication number Publication date
CN110391861A (en) 2019-10-29

Similar Documents

Publication Publication Date Title
CN108984370B (en) Method and device for determining monitoring threshold
CN110019339B (en) Data query method and system
US20140289428A1 (en) Dynamic Intervals for Synchronizing Data
CN111309747A (en) Data synchronization method, system and device
CN111046371A (en) Method, electronic device and computer-readable medium for generating device identification
CN110391861B (en) Method, device, equipment and storage medium for correcting timer
CN110795328A (en) Interface testing method and device
US11231869B2 (en) Method, electronic device, and computer program product for processing data
CN113760982A (en) Data processing method and device
US11734057B2 (en) Method and apparatus for processing a service of an abnormal server
CN111161072A (en) Block chain-based random number generation method, equipment and storage medium
CN111831503A (en) Monitoring method based on monitoring agent and monitoring agent device
CN111786801B (en) Method and device for charging based on data flow
CN110750424B (en) Resource inspection method and device
CN109087097B (en) Method and device for updating same identifier of chain code
CN110019671B (en) Method and system for processing real-time message
CN113535768A (en) Production monitoring method and device
CN112788075B (en) Business service monitoring method and device
CN112307060B (en) Method and device for processing picking task
CN113761001A (en) Cross-system data synchronization method and device
CN113612676B (en) Social group message synchronization method, device, equipment and storage medium
CN117319312B (en) Data flow control method and device
CN111199000B (en) Method and device for processing request
CN107707423B (en) Method, system, equipment and storage medium for acquiring network downloading speed
CN112882886A (en) Software use duration statistical method and device

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