CN111158999A - Method and device for calculating formatting time - Google Patents

Method and device for calculating formatting time Download PDF

Info

Publication number
CN111158999A
CN111158999A CN201911397351.XA CN201911397351A CN111158999A CN 111158999 A CN111158999 A CN 111158999A CN 201911397351 A CN201911397351 A CN 201911397351A CN 111158999 A CN111158999 A CN 111158999A
Authority
CN
China
Prior art keywords
time
formatting
core
current
timestamp
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
Application number
CN201911397351.XA
Other languages
Chinese (zh)
Other versions
CN111158999B (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.)
Hangzhou DPTech Technologies Co Ltd
Original Assignee
Hangzhou DPTech Technologies 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 Hangzhou DPTech Technologies Co Ltd filed Critical Hangzhou DPTech Technologies Co Ltd
Priority to CN201911397351.XA priority Critical patent/CN111158999B/en
Publication of CN111158999A publication Critical patent/CN111158999A/en
Application granted granted Critical
Publication of CN111158999B publication Critical patent/CN111158999B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F11/00Error detection; Error correction; Monitoring
    • G06F11/30Monitoring
    • G06F11/34Recording or statistical evaluation of computer activity, e.g. of down time, of input/output operation ; Recording or statistical evaluation of user activity, e.g. usability assessment
    • G06F11/3442Recording or statistical evaluation of computer activity, e.g. of down time, of input/output operation ; Recording or statistical evaluation of user activity, e.g. usability assessment for planning or managing the needed capacity
    • YGENERAL TAGGING OF NEW TECHNOLOGICAL DEVELOPMENTS; GENERAL TAGGING OF CROSS-SECTIONAL TECHNOLOGIES SPANNING OVER SEVERAL SECTIONS OF THE IPC; TECHNICAL SUBJECTS COVERED BY FORMER USPC CROSS-REFERENCE ART COLLECTIONS [XRACs] AND DIGESTS
    • Y02TECHNOLOGIES OR APPLICATIONS FOR MITIGATION OR ADAPTATION AGAINST CLIMATE CHANGE
    • Y02DCLIMATE CHANGE MITIGATION TECHNOLOGIES IN INFORMATION AND COMMUNICATION TECHNOLOGIES [ICT], I.E. INFORMATION AND COMMUNICATION TECHNOLOGIES AIMING AT THE REDUCTION OF THEIR OWN ENERGY USE
    • Y02D10/00Energy efficient computing, e.g. low power processors, power management or thermal management

Landscapes

  • Engineering & Computer Science (AREA)
  • General Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Computer Hardware Design (AREA)
  • Quality & Reliability (AREA)
  • Physics & Mathematics (AREA)
  • General Physics & Mathematics (AREA)
  • Debugging And Monitoring (AREA)

Abstract

The application provides a method and a device for calculating formatting time. A method of calculating a format time, comprising: the control core periodically collects a system time stamp as a reference time stamp; the control core calculates the reference formatting time corresponding to the reference timestamp and stores the corresponding relation between the reference timestamp and the reference formatting time; when the data core carries out formatting time calculation, acquiring a current system time stamp, a stored reference time stamp and reference formatting time corresponding to the reference time stamp; and the data core calculates the current formatting time according to the current system time stamp, the reference time stamp and the reference formatting time corresponding to the reference time stamp. According to the scheme, the control core and the data core can jointly complete the calculation of the formatting time, and compared with the prior art, the method can reduce the calculation pressure of the data core and improve the calculation efficiency of the formatting time.

Description

Method and device for calculating formatting time
Technical Field
The present application relates to the field of network communications, and in particular, to a method and an apparatus for calculating format time.
Background
Time is typically recorded internally in the network device in the form of a timestamp, which refers to the total number of seconds from 1970 to 00 seconds 01/1970 of greenwich mean time to the present, for example, a timestamp of 1546272000. Since the time stamp actually records seconds, information such as a specific year, month, and day cannot be intuitively known from the time stamp, it is necessary to convert the time stamp into a format time. The format time refers to a time having information of year, month, day, hour, minute, second, etc., and for example, the time stamp of 1546272000 described above is converted into the format time to obtain: 2019-01-0100:00:00.
For example, when the network device sends a log file, the network device needs to carry current formatting time, that is, before the network device sends the log file each time, the network device needs to obtain a current timestamp first, and then convert the current timestamp into corresponding formatting time. Because the calculation of converting the timestamp into the corresponding formatting time is complex, if the network device needs to send the log file frequently, the calculation of converting the timestamp into the formatting time needs to be executed once every time one log file is sent, and a large amount of processing resources of the network device are occupied.
Disclosure of Invention
In view of the above, the present application provides a method and an apparatus for calculating format time.
Specifically, the method is realized through the following technical scheme:
a calculation method of format time is applied to a multi-core network device and comprises the following steps:
the control core periodically collects a system time stamp as a reference time stamp;
the control core calculates the reference formatting time corresponding to the reference timestamp and stores the corresponding relation between the reference timestamp and the reference formatting time;
when the data core carries out formatting time calculation, acquiring a current system time stamp, a stored reference time stamp and reference formatting time corresponding to the reference time stamp;
and the data core calculates the current formatting time according to the current system time stamp, the reference time stamp and the reference formatting time corresponding to the reference time stamp.
A computing device for formatting time is applied to a multi-core network device and comprises:
the multi-core network device includes a control core including:
the acquisition unit is used for periodically acquiring the system time stamp as a reference time stamp;
the first calculating unit is used for calculating the reference formatting time corresponding to the reference timestamp and storing the corresponding relation between the reference timestamp and the reference formatting time;
the multi-core network device includes a data core including:
the acquisition unit is used for acquiring the current system time stamp, the stored reference time stamp and the reference formatting time corresponding to the reference time stamp when the formatting time is calculated;
and the second calculating unit is used for calculating the current formatting time according to the current system time stamp, the reference time stamp and the reference formatting time corresponding to the reference time stamp.
The application provides a method for calculating format time, wherein a control core can periodically acquire a system time stamp, the system time stamp is used as a reference time stamp, the control core calculates to obtain reference format time corresponding to the reference time stamp, and then the corresponding relation between the reference time stamp and the reference format time is stored. When the data core calculates the formatting time, the data core may obtain a current system timestamp, obtain a reference timestamp and reference formatting time calculated by the control core, and calculate the current formatting time based on the current system timestamp, the reference timestamp, and the reference formatting time corresponding thereto.
Compared with the prior art, the method can fully utilize the processing resources of the control core, reduce the calculation pressure of the data core and improve the calculation efficiency of the formatting time.
Drawings
FIG. 1 is a flow chart diagram illustrating a method for calculating a format time according to an exemplary embodiment of the present application;
FIG. 2 is a schematic structural diagram of a time-formatting computing device according to an exemplary embodiment of the present application;
FIG. 3 is a block diagram illustrating a time-formatted computing device according to an exemplary embodiment of the present application.
Detailed Description
Reference will now be made in detail to the exemplary embodiments, examples of which are illustrated in the accompanying drawings. When the following description refers to the accompanying drawings, like numbers in different drawings represent the same or similar elements unless otherwise indicated. The embodiments described in the following exemplary embodiments do not represent all embodiments consistent with the present application. Rather, they are merely examples of apparatus and methods consistent with certain aspects of the present application, as detailed in the appended claims.
The terminology used herein is for the purpose of describing particular embodiments only and is not intended to be limiting of the application. As used in this application and the appended claims, the singular forms "a", "an", and "the" are intended to include the plural forms as well, unless the context clearly indicates otherwise. It should also be understood that the term "and/or" as used herein refers to and encompasses any and all possible combinations of one or more of the associated listed items.
It is to be understood that although the terms first, second, third, etc. may be used herein to describe various information, such information should not be limited to these terms. These terms are only used to distinguish one type of information from another. For example, first information may also be referred to as second information, and similarly, second information may also be referred to as first information, without departing from the scope of the present application. The word "if" as used herein may be interpreted as "at … …" or "when … …" or "in response to a determination", depending on the context.
The network device generally records time in a time stamp manner, and in some scenarios, the network device needs to convert the time stamp into corresponding formatted time. For example, when the network device sends a log, the network device needs to carry current formatting time, and then the network device needs to obtain a current system timestamp first, and then calculate the current system timestamp to obtain corresponding current formatting time.
Taking the multi-core network device as an example, the multi-core network device may include a control core and a data core, where the control core and the data core are usually implemented by different CPUs (central processing units) and may perform different tasks. The data core may be used to process business processes and the control core may be used for system management. The multi-core network device generally sends the log file through the data core, and the data core needs to acquire the system time stamp firstly and then convert the system time stamp into corresponding formatting time, and then can send the log file.
The computation of converting the system timestamp to the format time is complex and requires a large amount of processing resources. For example, the system timestamp is 1546272000, which corresponds to a formatting time of 2019-01-0100: 00: 00. In performing the format time calculation, the formula may be utilized: and (timeStamp/60)% 60, calculating a second-place value of the formatting time, wherein min is the second-place value, timeStamp is a timeStamp, and% is a remainder operation. Substituting the system timestamp into a formula to obtain: min ═ 1546272000/60% 60 ═ 0, namely, the second-place value of the formatting time corresponding to the system timestamp is 0. Then, the formula can also be used: sec is the quantile value of formatting time calculated as% 60, where sec is the quantile value, timeStamp is the timeStamp, and% is the remainder operation. Substituting the system timestamp into a formula to obtain: and sec is 1546272000%, 60 is 0, that is, the quantile value of the formatting time corresponding to the system timestamp is 0.
In addition to the above-described calculation of seconds and minutes, converting the system timestamp to a format time involves the calculation of year, month, day, etc. information, which is more complicated. Each time the data core sends a log file, complex calculation for converting the system timestamp into the formatting time needs to be performed once, which occupies a large amount of processing resources of the data core.
Based on the above, the application provides a method and a device for calculating formatting time.
According to the scheme, the control core and the data core can jointly complete the calculation of the formatting time.
Firstly, the control core periodically acquires a system time stamp, the system time stamp is used as a reference time stamp, the control core calculates and obtains reference formatting time corresponding to the reference time stamp, and then the corresponding relation between the reference time stamp and the reference formatting time is stored. When the data core calculates the formatting time, only the current system time stamp needs to be acquired, the reference time stamp and the reference formatting time which are calculated by the control core are acquired, then a first difference value between the current system time stamp and the reference time stamp can be calculated, and the current formatting time can be calculated according to the first difference value and the reference formatting time.
According to the scheme, the data core and the control core can jointly complete the calculation of converting the system time stamp into the corresponding formatting time, the control core is equivalent to share the calculation of a part of data cores, and the processing resources of the control core are fully utilized. According to the method and the device, the data core only needs to execute simple operation on the current system timestamp, the reference timestamp and the reference formatting time, and compared with the complex operation of the formatting time calculation in the prior art, the calculation pressure of the data core can be greatly reduced, and meanwhile, the calculation efficiency of the formatting time can be improved.
Fig. 1 is a flowchart illustrating a method for calculating a format time according to an exemplary embodiment of the present application.
The calculation method of the format time can be applied to a multi-core network device, and the multi-core network device can comprise a data core and a control core. The data core and the control core may be located on the same physical device.
Of course, when the method for calculating the format time provided by the present application is applied to a network device cluster, the data core and the control core may also be located in different physical devices, and the present application does not specially limit this.
Referring to fig. 1, the method for calculating the format time may include the following steps:
step 102, the control core periodically collects a system time stamp as a reference time stamp.
And 104, calculating the reference formatting time corresponding to the reference timestamp by the control core, and storing the corresponding relation between the reference timestamp and the reference formatting time.
In the application, after the multi-core network device is started, the control core starts to acquire the reference timestamp.
In one example, after acquiring a first reference timestamp, the control core calculates a reference formatting time corresponding to the reference timestamp. And after the control core collects the first reference timestamp, the system timestamp can be periodically collected in a preset time period, the collected system timestamp is used as the reference timestamp, and corresponding reference formatted data is calculated.
The time period may be determined artificially, for example 30 seconds, 60 seconds, etc. Preferably, the time period may be set to 60 seconds. Since 1 minute is equal to 60 seconds, when the second value of the reference formatting time is a preset value 0, 60 seconds are used as a time period, and the second value of the reference formatting time calculated by the control core in each time period is 0, so that the calculation of the subsequent data core is facilitated.
In this step, the specific method for converting the reference timestamp into the reference format time by the control core refers to the prior art, and this application is not described herein too much.
In another example, the control core calculates a reference formatting time corresponding to the reference time stamp after acquiring the first reference time stamp. And then the control core can also judge whether the second bit value of the formatting time is a preset value. If yes, the control core can periodically acquire the system time stamp as the reference time stamp in a preset time period.
For example, the preset time period is 60 seconds, the preset value is 0, and assuming that the control core randomly acquires a current system timestamp of 1546272000, converting the system timestamp 1546272000 into a corresponding format time to obtain: 2019-01-0100: 00:00, if the second bit value of the formatting time is judged to be 0 by the control core and is the same as the preset value 0, the control core may then periodically acquire a system time stamp as a reference time stamp according to a time period of 60 seconds, and may calculate the reference formatting time corresponding to the reference time stamp after acquiring one reference time stamp.
If not, the control core may adjust the acquisition time of the next reference timestamp according to the second bit value of the format time.
For example, the preset time period is still 60 seconds, the preset value is still 0, and assuming that the control core randomly acquires a current system timestamp of 1546272010, the system timestamp 1546272010 is converted into a corresponding format time to obtain: 2019-01-0100:00:10. And the control core judges that the second value of the formatting time is 10, and if the second value is different from the preset value of 0, the control core can adjust the acquisition time of the next reference timestamp and determine the next acquisition time as the difference value between the preset time period and the second value, namely 50 seconds. Then the next system timestamp collected by the control core is 1546272060, and the control core converts 1546272060 into the corresponding format time to obtain: 2019-01-0100: 01:00, if the second bit value is a preset value 0, the control core may then periodically acquire a system timestamp as a reference timestamp according to a time period of 60 seconds, and may calculate a reference formatting time corresponding to the reference timestamp after acquiring one reference timestamp.
In practical applications, a timer may be further set to realize the periodic acquisition of the reference time stamp.
For example, the timing duration of the timer may be set to the time period, and when the timing duration reaches the time period, the control core performs an operation of acquiring the system timestamp. By the above method, the control core may periodically acquire the reference time stamp.
For the above situation that the acquisition time of the next reference timestamp needs to be adjusted, the acquisition time can also be realized based on a timer, and details are not repeated herein.
It should be noted that there may be an error after the system runs for a long time, for example, the preset timing duration of the timer is 60 seconds, but in practical cases, the timing duration of the timer running may be 59.99 seconds, and after a long time, the second value of the reference formatting time corresponding to the reference timestamp acquired based on the inaccurate timing duration may not be the preset value, so in some cases, it is necessary to determine whether the second value of the reference formatting time is the preset value.
For example, the control core may periodically determine whether a second value of the reference formatting time obtained in the current time period is a preset value, and if so, no adjustment is required; if not, the acquisition time of the next reference timestamp can be adjusted according to the second position value of the reference formatting time, and after the calculated second position value of the reference formatting time is changed into a preset numerical value again, the acquisition of the reference timestamp can be continued according to a preset time period. The determination period of the reference formatting time-second value may be set to 1 day, 3 days, etc., and this application does not limit this.
In the application, after the control core acquires the reference timestamp and calculates the corresponding reference formatting time, the corresponding relationship between the reference timestamp and the reference formatting time can be stored.
For example, the control core may store the correspondence in a memory shared by the data core or the control core. The control core can access the memory to store the corresponding relation; the data core may also access the memory to obtain the correspondence.
Of course, the control core may also send the corresponding relationship to the data core, and the data core stores the corresponding relationship, which is not limited in this application.
In this application, the control core may further store the corresponding relationship in the form of a global variable array. The global variable array comprises two variables, namely a reference timestamp and a reference formatting time, and the two variables are updated along with different time periods, namely the control core can replace the stored reference timestamp obtained in the last time period and the stored reference formatting time by using the reference timestamp obtained in the current time period and the reference formatting time corresponding to the reference timestamp.
And 106, when the data core calculates the formatting time, acquiring the current system time stamp, the stored reference time stamp and the reference formatting time corresponding to the reference time stamp.
And step 108, the data core calculates the current formatting time according to the current system time stamp, the reference time stamp and the reference formatting time corresponding to the reference time stamp.
In the present application, when the data core performs the format time calculation, the format time calculation scheme provided in the present application may be executed.
For example, when the data core needs to carry the log sending time when sending the log file, the current system timestamp can be obtained, and then the current formatting time corresponding to the current system timestamp is obtained by using the reference timestamp and the reference formatting time in the present application.
For another example, when the data core records the service operation of the user, for example, when the user uploads or downloads a file, the upload and download time of the user also needs to be recorded, and then based on the scheme of the present application, the current formatting time corresponding to the current system timestamp may be calculated by using the reference timestamp and the reference formatting time, which is not limited in this application.
In the method and the device, after the data core obtains the current system timestamp, the stored reference timestamp and the reference formatting time corresponding to the current system timestamp, a first difference value between the current system timestamp and the reference timestamp can be calculated, and the current formatting time is determined according to the first difference value and the reference formatting time.
Preferably, the data core may add the second bit value of the reference formatting time to the first difference value, and determine whether the second bit value of the time obtained after the addition is less than 60.
In this example, the reason why the second-place value of the time obtained after the addition is judged to be less than 60 is that the data core needs to take different measures for the case where the second-place value of the time obtained after the addition is less than 60 and greater than or equal to 60. For the condition that the second bit value is less than 60, other operations are not needed, and the time obtained after the addition can be directly used as the current formatting time; for the case that the second value is greater than or equal to 60, since the timing rule that 1 minute is equal to 60 seconds is not met, the time obtained after the addition needs to be further calculated to obtain the current formatting time.
The following specifically describes the case where the second-order value of the time obtained by the addition is less than 60 and not less than 60:
and if the second-place value of the time obtained after the addition is less than 60, determining the time obtained after the addition as the current formatting time by the data core.
For example, the reference timestamp is 1546272000, the corresponding reference formatting time is 2019-01-0100: 00:00, and the current system timestamp is 1546272040, then the data core calculates a difference between the current system timestamp and the reference timestamp, and obtains the first difference as: 1546272040-. The data core may add the first difference to the second bit value of the reference formatting time to obtain an added time as: 2019-01-0100:00:40. And the data core further judges that the second-place value of the time obtained after the addition is 40 and is less than 60, and the data core determines the time 2019-01-0100: 00:40 obtained after the addition as the current formatting time.
If the second value of the added time is greater than or equal to 60, the data core may calculate the current formatting time by the following two methods:
1) the data core can adjust the decimal value, the second-place value and the like of the time obtained after the addition to obtain the current formatting time.
For example, the reference timestamp is 1546272050, the corresponding reference formatting time is 2019-01-0100: 00:50, and the current system timestamp is 1546272090, then the data core calculates a difference between the current system timestamp and the reference timestamp, and obtains the first difference as: 1546272090 ═ 40 (1546272050). The data core may add the first difference to the second bit value of the reference formatting time to obtain an added time as: 2019-01-0100:00:90. The data core further judges that the second value of the time obtained after the addition is 90 and is more than 60, and obviously does not accord with the timing rule that 1 minute is equal to 60 seconds.
Therefore, in this example, the data core may adjust the quantile value and the second bit value of the added time to obtain the calculated time of 2019-01-0100: 01:30 by using the quantile value +1 and the second bit value-60. And taking the calculated time as the current formatting time.
2) The data core may also send a reference formatting time update instruction to the control core, and then calculate the current formatting time based on the updated reference timestamp and its corresponding reference formatting time.
In this example, since the second bit value of the calculated time is greater than 60, it may be that the second bit value of the reference formatting time is not 0, for example, the second bit value of the reference formatting time is 50, when the subsequent data core acquires the system timestamp and calculates the corresponding formatting time thereof, the second bit value of the calculated time may be greater than 60, and thus the data core may request the control core to update the reference formatting time.
Of course, it may also be that the control core does not update the reference formatting time of the current time period in time, so that the data core performs the calculation using the reference formatting time of the previous time period, and the second bit value of the calculated time may be greater than 60, so that the reference formatting time also needs to be updated.
In particular, the data core may send a reference formatting time update instruction to the control core. And after receiving the instruction, the control core executes the steps of acquiring the reference timestamp and calculating the reference formatting time corresponding to the reference timestamp. And after the control core calculates the reference formatting time, judging whether the second value of the reference formatting time is a preset value.
And if so, the control core sends an updated message to the data core.
If not, the control core may calculate a second difference between the time period and the second bit value, acquire a next reference timestamp based on the second difference, and calculate a reference formatting time corresponding to the next reference timestamp after the acquisition, and the control core may store the next reference timestamp and the reference formatting time corresponding to the next reference timestamp, and send an updated message to the data core.
And after receiving the updated message, the data core can acquire the updated reference timestamp and the reference formatting time corresponding to the updated reference timestamp, and then calculate the current formatting time.
For example, the reference timestamp is 1546272000, the corresponding reference formatting time is 2019-01-0100: 00:00, and the current system timestamp is 1546272090, then the data core calculates a difference between the current system timestamp and the reference timestamp, and obtains the first difference as: 1546272090 ═ 90 of 1546272000. The data core may add the first difference to the second bit value of the reference formatting time to obtain an added time as: 2019-01-0100:00:90. The data core further determines that the second bit value of the time obtained after the addition is 90 and is greater than 60, and the data core may send a reference formatting time update instruction to the control core.
And after receiving the instruction, the control core acquires that the current system timestamp is assumed to be 1546272100, calculates the second value of the reference formatting time to be 2019-01-0100: 01:40, and then judges that the second value of the reference formatting time is 40 and is not a preset value of 0. The control core may therefore calculate the difference between 60 and the second bit value, i.e. calculate: and 60-40, acquiring the next system timestamp after 20 seconds by the control core to obtain 1546272120, and calculating 1546272120 corresponding formatting time to be 2019-01-0100: 02:00 and the second bit value to be a preset value of 0. The control core may save the reference timestamp 1546272120 and the corresponding formatting time 2019-01-0100: 02:00 and send an updated message to the data core.
After receiving the updated message, the data core may calculate the current formatting time based on the updated reference timestamp and the reference formatting time corresponding thereto.
For example, after receiving the message, the data core may obtain the current system timestamp again, and still in the above example, the data core obtains 1546272130 the current system timestamp again, calculates a first difference between the current system timestamp and the reference timestamp, that is, 1546272130 and 1546272120 are equal to 10, and adds the first difference and the reference formatting time to obtain 2019-01-0100: 02:10 as the current formatting time.
As can be seen from the above description, in the present application, the control core may periodically acquire the system timestamp as the reference timestamp and calculate the corresponding reference formatting time, and then store the corresponding relationship between the reference timestamp and the reference formatting time. When the data core calculates the formatting time, after acquiring the current system timestamp, the data core may acquire the stored reference timestamp and the reference formatting time, and then may calculate a first difference between the current system timestamp and the reference timestamp, and may calculate the current formatting time according to the first difference and the reference formatting time.
According to the scheme, the data core and the control core can jointly complete the calculation of converting the system time stamp into the corresponding formatting time, the control core is equivalent to share the calculation of a part of data cores, and the processing resources of the control core are fully utilized. And the data core only needs to execute simpler operation on the current system time stamp, the reference time stamp and the reference format time, so that the calculation pressure of the data core can be greatly reduced and the calculation efficiency of the format time can be improved compared with the complex operation of the format time calculation in the prior art.
Corresponding to the embodiment of the method for calculating the formatting time, the application also provides an embodiment of a device for calculating the formatting time.
The embodiment of the computing device for formatting the time can be applied to a server. The device embodiments may be implemented by software, or by hardware, or by a combination of hardware and software. Taking a software implementation as an example, as a logical device, the device is formed by reading corresponding computer program instructions in the nonvolatile memory into the memory for operation through the processor of the server where the device is located. In terms of hardware, as shown in fig. 2, a hardware structure diagram of a server where a computing device of the present application formats time is located is shown, except for the processor, the memory, the network interface, and the nonvolatile memory shown in fig. 2, the server where the device is located in the embodiment may also include other hardware according to the actual function of the server, which is not described again.
FIG. 3 is a block diagram illustrating a time-formatted computing device according to an exemplary embodiment of the present application.
Referring to fig. 3, the computing apparatus 300 for formatting time can be applied to the server shown in fig. 2, and includes: the device comprises an acquisition unit 310, a first calculation unit 320, an acquisition unit 330 and a second calculation unit 340. Wherein the multi-core network device comprises a control core, the control core comprising:
an acquisition unit 310, configured to periodically acquire a system timestamp as a reference timestamp;
a first calculating unit 320, configured to calculate a reference formatting time corresponding to the reference timestamp, and store a corresponding relationship between the reference timestamp and the reference formatting time;
the multi-core network device includes a data core, the data core including:
an obtaining unit 330, configured to obtain a current system timestamp, a stored reference timestamp, and a reference formatting time corresponding to the stored reference timestamp when performing formatting time calculation;
the second calculating unit 340 is configured to calculate a current formatting time according to the current system timestamp, the reference timestamp, and a reference formatting time corresponding thereto.
Optionally, the second calculating unit 340 is specifically configured to:
the data core calculates a first difference value between the current system time stamp and the stored reference time stamp;
and the data core determines the current formatting time according to the first difference and the reference formatting time.
Optionally, the determining, by the data core, the current formatting time according to the first difference and the reference formatting time includes:
the data core adds the first difference value to a second bit value of the reference formatting time;
the data core judges whether the second value of the time obtained after the addition is less than 60;
and if the sum is smaller than the current formatting time, the data core determines the time obtained after the addition as the current formatting time.
Optionally, the method further includes:
and if the current formatting time is larger than or equal to the current formatting time, formatting the time obtained after the data check and the addition to obtain the current formatting time.
Optionally, the method further includes:
if the reference formatting time is larger than or equal to the reference formatting time, the data core sends a reference formatting time updating instruction to the control core;
after receiving the instruction, the control core executes the steps of collecting a reference time stamp and calculating reference formatting time corresponding to the reference time stamp;
after the control core calculates the reference formatting time, judging whether the second bit value of the reference formatting time is 0, if so, sending an updated message to the data core;
and after receiving the updated message, the data core re-executes the calculation step of the current formatting time.
Optionally, the method further includes:
if not, the control core calculates a second difference value between 60 and the second bit value;
and the control core acquires the next reference time stamp based on the second difference value, and periodically acquires the reference time stamp by taking 60 seconds as a time period after the next reference time stamp is acquired.
Optionally, when the corresponding relationship between the reference timestamp and the reference formatting time is saved, the first calculating unit 320 is specifically configured to:
and the control core replaces the corresponding relation between the reference timestamp acquired in the previous time period and the reference formatting time corresponding to the reference timestamp acquired in the previous time period with the corresponding relation between the reference timestamp acquired in the current time period and the reference formatting time corresponding to the reference timestamp.
The implementation process of the functions and actions of each unit in the above device is specifically described in the implementation process of the corresponding step in the above method, and is not described herein again.
For the device embodiments, since they substantially correspond to the method embodiments, reference may be made to the partial description of the method embodiments for relevant points. The above-described embodiments of the apparatus are merely illustrative, and the units described as separate parts may or may not be physically separate, and parts displayed as units may or may not be physical units, may be located in one place, or may be distributed on a plurality of network units. Some or all of the modules can be selected according to actual needs to achieve the purpose of the scheme of the application. One of ordinary skill in the art can understand and implement it without inventive effort.
The systems, devices, modules or units illustrated in the above embodiments may be implemented by a computer chip or an entity, or by a product with certain functions. A typical implementation device is a computer, which may take the form of a personal computer, laptop computer, cellular telephone, camera phone, smart phone, personal digital assistant, media player, navigation device, email messaging device, game console, tablet computer, wearable device, or a combination of any of these devices.
The above description is only exemplary of the present application and should not be taken as limiting the present application, as any modification, equivalent replacement, or improvement made within the spirit and principle of the present application should be included in the scope of protection of the present application.

Claims (10)

1. A method for calculating format time is applied to a multi-core network device, and comprises the following steps:
the control core periodically collects a system time stamp as a reference time stamp;
the control core calculates the reference formatting time corresponding to the reference timestamp and stores the corresponding relation between the reference timestamp and the reference formatting time;
when the data core carries out formatting time calculation, acquiring a current system time stamp, a stored reference time stamp and reference formatting time corresponding to the reference time stamp;
and the data core calculates the current formatting time according to the current system time stamp, the reference time stamp and the reference formatting time corresponding to the reference time stamp.
2. The method of claim 1, wherein calculating, by the data core, a current formatting time based on the current system timestamp, the reference timestamp, and a reference formatting time corresponding thereto comprises:
the data core calculates a first difference value between the current system time stamp and the stored reference time stamp;
and the data core determines the current formatting time according to the first difference and the reference formatting time.
3. The method of claim 2, wherein determining, by the data core, the current formatting time based on the first difference and the reference formatting time comprises:
the data core adds the first difference value to a second bit value of the reference formatting time;
the data core judges whether the second value of the time obtained after the addition is less than 60;
and if the sum is smaller than the current formatting time, the data core determines the time obtained after the addition as the current formatting time.
4. The method of claim 3, further comprising:
and if the current formatting time is larger than or equal to the current formatting time, formatting the time obtained after the data check and the addition to obtain the current formatting time.
5. The method of claim 3, further comprising:
if the reference formatting time is larger than or equal to the reference formatting time, the data core sends a reference formatting time updating instruction to the control core;
after receiving the instruction, the control core executes the steps of collecting a reference time stamp and calculating reference formatting time corresponding to the reference time stamp;
after the control core calculates the reference formatting time, judging whether the second bit value of the reference formatting time is 0, if so, sending an updated message to the data core;
and after receiving the updated message, the data core re-executes the calculation step of the current formatting time.
6. The method of claim 5, further comprising:
if not, the control core calculates a second difference value between 60 and the second bit value;
and the control core acquires the next reference time stamp based on the second difference value, and periodically acquires the reference time stamp by taking 60 seconds as a time period after the next reference time stamp is acquired.
7. The method of claim 1, wherein saving the reference timestamp and the reference format time correspondence comprises:
and the control core replaces the corresponding relation between the reference timestamp acquired in the previous time period and the reference formatting time corresponding to the reference timestamp acquired in the previous time period with the corresponding relation between the reference timestamp acquired in the current time period and the reference formatting time corresponding to the reference timestamp.
8. A computing apparatus for formatting time, applied to a multi-core network device, the apparatus comprising:
the multi-core network device includes a control core including:
the acquisition unit is used for periodically acquiring the system time stamp as a reference time stamp;
the first calculating unit is used for calculating the reference formatting time corresponding to the reference timestamp and storing the corresponding relation between the reference timestamp and the reference formatting time;
the multi-core network device includes a data core, the data core including:
the acquisition unit is used for acquiring the current system time stamp, the stored reference time stamp and the reference formatting time corresponding to the reference time stamp when the formatting time is calculated;
and the second calculating unit is used for calculating the current formatting time according to the current system time stamp, the reference time stamp and the reference formatting time corresponding to the reference time stamp.
9. The apparatus according to claim 2, wherein the second computing unit is specifically configured to:
the data core calculates a first difference value between the current system time stamp and the stored reference time stamp;
and the data core determines the current formatting time according to the first difference and the reference formatting time.
10. The apparatus of claim 9, wherein the data core determines the current formatting time based on the first difference and the reference formatting time, comprising:
the data core adds the first difference value to a second bit value of the reference formatting time;
the data core judges whether the second value of the time obtained after the addition is less than 60;
and if the sum is smaller than the current formatting time, the data core determines the time obtained after the addition as the current formatting time.
CN201911397351.XA 2019-12-30 2019-12-30 Formatting time calculation method and device Active CN111158999B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201911397351.XA CN111158999B (en) 2019-12-30 2019-12-30 Formatting time calculation method and device

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201911397351.XA CN111158999B (en) 2019-12-30 2019-12-30 Formatting time calculation method and device

Publications (2)

Publication Number Publication Date
CN111158999A true CN111158999A (en) 2020-05-15
CN111158999B CN111158999B (en) 2023-05-26

Family

ID=70559274

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201911397351.XA Active CN111158999B (en) 2019-12-30 2019-12-30 Formatting time calculation method and device

Country Status (1)

Country Link
CN (1) CN111158999B (en)

Cited By (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN111651338A (en) * 2020-05-28 2020-09-11 杭州迪普科技股份有限公司 Log formatting time acquisition system and method thereof
CN111913445A (en) * 2020-05-29 2020-11-10 北京寄云鼎城科技有限公司 Data acquisition method, data acquisition equipment, storage medium, data transmission method and gateway
CN112419698A (en) * 2020-10-26 2021-02-26 浙江正泰仪器仪表有限责任公司 Electric energy meter data transmission method, system and device based on distribution line message specification

Citations (13)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
WO2012060765A1 (en) * 2010-11-04 2012-05-10 Telefonaktiebolaget L M Ericsson (Publ) Methods and arrangements for time-stamping of reports
US20120266010A1 (en) * 2011-04-14 2012-10-18 International Business Machines Corporation Conversion of timestamps between multiple entities within a computing system
CN102750192A (en) * 2012-06-06 2012-10-24 杭州华三通信技术有限公司 Method and device for data plane anomaly detection
US20120301121A1 (en) * 2011-05-23 2012-11-29 Renesas Electronics Corporation Data processing system
CN102821114A (en) * 2011-06-07 2012-12-12 南京中兴新软件有限责任公司 Distributed memory system and implementation method of timestamps thereof
US20130080710A1 (en) * 2011-09-28 2013-03-28 Emc Corporation Hardware method for detecting timeout conditions in a large number of data connections
US8938636B1 (en) * 2012-05-18 2015-01-20 Google Inc. Generating globally coherent timestamps
EP2856356A2 (en) * 2012-06-04 2015-04-08 Google, Inc. Systems and methods of increasing database access concurrency using granular timestamps
US20150200863A1 (en) * 2012-10-24 2015-07-16 Google Inc. System and method for updating timestamps in log data
US20160253337A1 (en) * 2015-02-26 2016-09-01 Unisys Corporation System and method for converting a format of a time stamp
US20160253338A1 (en) * 2015-02-26 2016-09-01 Unisys Corporation System and method for displaying time in a single-word utc time stamp
US9720441B1 (en) * 2016-09-30 2017-08-01 International Business Machines Corporation Generating time-of-day values without causing execution stalls
US20190146849A1 (en) * 2017-11-16 2019-05-16 Sas Institute Inc. Scalable cloud-based time series analysis

Patent Citations (13)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
WO2012060765A1 (en) * 2010-11-04 2012-05-10 Telefonaktiebolaget L M Ericsson (Publ) Methods and arrangements for time-stamping of reports
US20120266010A1 (en) * 2011-04-14 2012-10-18 International Business Machines Corporation Conversion of timestamps between multiple entities within a computing system
US20120301121A1 (en) * 2011-05-23 2012-11-29 Renesas Electronics Corporation Data processing system
CN102821114A (en) * 2011-06-07 2012-12-12 南京中兴新软件有限责任公司 Distributed memory system and implementation method of timestamps thereof
US20130080710A1 (en) * 2011-09-28 2013-03-28 Emc Corporation Hardware method for detecting timeout conditions in a large number of data connections
US8938636B1 (en) * 2012-05-18 2015-01-20 Google Inc. Generating globally coherent timestamps
EP2856356A2 (en) * 2012-06-04 2015-04-08 Google, Inc. Systems and methods of increasing database access concurrency using granular timestamps
CN102750192A (en) * 2012-06-06 2012-10-24 杭州华三通信技术有限公司 Method and device for data plane anomaly detection
US20150200863A1 (en) * 2012-10-24 2015-07-16 Google Inc. System and method for updating timestamps in log data
US20160253337A1 (en) * 2015-02-26 2016-09-01 Unisys Corporation System and method for converting a format of a time stamp
US20160253338A1 (en) * 2015-02-26 2016-09-01 Unisys Corporation System and method for displaying time in a single-word utc time stamp
US9720441B1 (en) * 2016-09-30 2017-08-01 International Business Machines Corporation Generating time-of-day values without causing execution stalls
US20190146849A1 (en) * 2017-11-16 2019-05-16 Sas Institute Inc. Scalable cloud-based time series analysis

Cited By (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN111651338A (en) * 2020-05-28 2020-09-11 杭州迪普科技股份有限公司 Log formatting time acquisition system and method thereof
CN111913445A (en) * 2020-05-29 2020-11-10 北京寄云鼎城科技有限公司 Data acquisition method, data acquisition equipment, storage medium, data transmission method and gateway
CN111913445B (en) * 2020-05-29 2022-07-26 北京寄云鼎城科技有限公司 Data acquisition method, data acquisition equipment, storage medium, data transmission method and gateway
CN112419698A (en) * 2020-10-26 2021-02-26 浙江正泰仪器仪表有限责任公司 Electric energy meter data transmission method, system and device based on distribution line message specification

Also Published As

Publication number Publication date
CN111158999B (en) 2023-05-26

Similar Documents

Publication Publication Date Title
CN110321387B (en) Data synchronization method, equipment and terminal equipment
CN107766575B (en) Read-write separation database access method and device
CN109495318B (en) Mobile communication network flow prediction method, device and readable storage medium
CN111158999B (en) Formatting time calculation method and device
CN109634819B (en) Alarm root cause positioning method and device and electronic equipment
CN111478963B (en) Message pushing method and device, electronic equipment and computer readable storage medium
US9292336B1 (en) Systems and methods providing optimization data
CN109388550B (en) Cache hit rate determination method, device, equipment and readable storage medium
CN109992473B (en) Application system monitoring method, device, equipment and storage medium
CN112559475B (en) Data real-time capturing and transmitting method and system
CN111222089B (en) Data processing method, data processing device, computer equipment and storage medium
CN109726983A (en) Examine method for allocating tasks, device, computer equipment and storage medium
CN111506580B (en) Transaction storage method based on centralized block chain type account book
CN112559592A (en) Real-time data processing method, device and equipment
CN111311014B (en) Service data processing method, device, computer equipment and storage medium
CN109359109B (en) Data processing method and system based on distributed stream computing
CN111078418B (en) Operation synchronization method, device, electronic equipment and computer readable storage medium
CN111984677A (en) Resource data checking method and device, computer equipment and storage medium
CN111258854A (en) Model training method, alarm method based on prediction model and related device
CN112416568A (en) Duration estimation method and duration estimation device for audio and video transcoding task
CN115174686B (en) Method and device for dynamically adjusting weights of multiple service channels based on service efficiency
CN108429632B (en) Service monitoring method and device
CN111564165B (en) Data storage method, device, equipment and storage medium
CN110148044B (en) Method and device for setting buffering threshold for accounting
CN113382088A (en) Mobile banking message pushing 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