pimd: Add the ability to get time in usec

Add ability to return a int64_t time in usec.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
This commit is contained in:
Donald Sharp 2016-10-27 12:26:00 -04:00
parent e5905a3bc3
commit 8a9bd91cd9
2 changed files with 20 additions and 0 deletions

View File

@ -83,6 +83,25 @@ int64_t pim_time_monotonic_dsec()
return now_dsec;
}
int64_t
pim_time_monotonic_usec (void)
{
struct timeval now_tv;
int64_t now_dsec;
if (gettime_monotonic(&now_tv)) {
zlog_err("%s: gettime_monotonic() failure: errno=%d: %s",
__PRETTY_FUNCTION__,
errno, safe_strerror(errno));
return -1;
}
now_dsec = ((int64_t) now_tv.tv_sec) * 1000000 + ((int64_t) now_tv.tv_usec);
return now_dsec;
}
int pim_time_mmss(char *buf, int buf_size, long sec)
{
long mm;

View File

@ -29,6 +29,7 @@
int64_t pim_time_monotonic_sec(void);
int64_t pim_time_monotonic_dsec(void);
int64_t pim_time_monotonic_usec(void);
int pim_time_mmss(char *buf, int buf_size, long sec);
void pim_time_timer_to_mmss(char *buf, int buf_size, struct thread *t);
void pim_time_timer_to_hhmmss(char *buf, int buf_size, struct thread *t);